hapijs 你好,世界
示例
创建一个server.js具有以下内容的文件:
'use strict';
const Hapi = require('hapi');
//创建服务器实例
const server = new Hapi.Server();
// Specify connections (server available on http://localhost:8000)
server.connection({
port: 8000
});
//添加路线
server.route({
method: 'GET',
path:'/hello',
handler: function (request, reply) {
return reply('hello world');
}
});
//启动服务器
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});启动Hapi.js服务器
运行nodeserver.js并在浏览器中打开http://localhost:8000/hello。
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短