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 婶婶拜年祝福语大全简短