[Hapi.js] Up and running
hapi is a rock solid server framework for Node.js. Its focus on modularity and configuration-over-convention makes it the perfect match for any size development team.
Install:
npm install --save hapi
index.js
'use strict'
var Hapi = require( 'hapi' ); var server = new Hapi.Server();
server.connection( {
host: 'localhost',
port: 8000
} ); server.route( {
method: 'GET',
path: '/',
handler: function ( request, reply ) {
reply( 'hello hapi!' )
}
} ); server.route( {
method: 'GET',
path: '/{name}',
handler: function ( request, reply ) {
reply( "hello " + request.params.name + "!" );
}
} ); server.start( function () {
console.log( 'Started at:', server.info.uri )
} );
RUN:
node index.js
[Hapi.js] Up and running的更多相关文章
- [Hapi.js] View engines
View engines, or template engines, allow you to maintain a clean separation between your presentatio ...
- [Hapi.js] Managing State with Cookies
hapi has built-in support for parsing cookies from a request headers, and writing cookies to a respo ...
- [Hapi.js] Request Validation with Joi
hapi supports request validation out of the box using the joi module. Request path parameters, paylo ...
- [Hapi.js] Friendly error pages with extension events
hapi automatically responds with JSON for any error passed to a route's reply()method. But what if y ...
- [Hapi.js] Extending the request with lifecycle events
Instead of using middlware, hapi provides a number of points during the lifecycle of a request that ...
- [Hapi.js] POST and PUT request payloads
hapi makes handling POST and PUT payloads easy by buffering and parsing them automatically without r ...
- [Hapi.js] Serving static files
hapi does not support serving static files out of the box. Instead it relies on a module called Iner ...
- [Hapi.js] Replying to Requests
hapi's reply interface is one of it's most powerful features. It's smart enough to detect and serial ...
- [Hapi.js] Route parameters
Routing is a fundamental aspect of any framework. In this lesson, you'll learn how to use path param ...
随机推荐
- 微软HoloLens虚拟现实可以开发了。
1.microsoft-hololens-now-available-to-developers 2.http://www.microsoft.com/microsoft-hololens/en-us ...
- angular 指令梳理 —— checkBox
checkBox 持久化数据为 逗号分割 /** * 功能说明: * htCheckbox 指令用于收集checkbox数据. * 在页面中使用 * 属性指令:ht-checkbox * 对应的值为s ...
- python进行base64编解码
[转] 直接上代码 import base64 fin = open(r"D:\2.zip", "rb") fout = open(r"D:\2.x. ...
- The Time in Words
def main(): time = ["one", "two", "three", "four", "fiv ...
- memcached的安装
最近在研究怎么让Discuz!去应用Memcache去做一些事情,记录下Memcache安装的过程. Linux下Memcache服务器端的安装 服务器端主要是安装memcache服务器端,目前的最新 ...
- nyoj-366-D的小L(求全排列)
D的小L 时间限制:4000 ms | 内存限制:65535 KB 难度:2 描述 一天TC的匡匡找ACM的小L玩三国杀,但是这会小L忙着哩,不想和匡匡玩但又怕匡匡生气,这时小L给匡匡 ...
- 在Mac上使用vundle自动安装vim插件,并用vim代替sourceinsight
一直以来在Mac上找不到好的代码阅读工具,最近根据网上的教程,自己总结一下,做了个在Mac的类sourceinsight的vim,感觉很好用.我不喜欢那种把vim搞的很复杂的配置,所以做了个仅仅能满足 ...
- VS2010中<无法打开包括文件:“iostream.h”:>错误解决方法
C/C++ code? 1 2 #include <iostream.h> 改为: C/C++ code? 1 2 #include <iostream> using name ...
- 去除winXP访问共享的“记住密码”
控制面板->用户帐户,选择自己的用户,在左侧的管理我的网络密码里有删除选项 控制面板-->用户-->点击你登陆用户-->点击左上角“管理我的网络密码”-->在列表中删除密 ...
- ListView 实现分组
1:FragmentHack4.java /** * Created by y on 15-1-2. */ public class FragmentHack4 extends Fragment{ V ...