[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 ...
随机推荐
- Android ActionBar详解(一):ActionBar概述及其创建
在Android 3.0中除了我们重点讲解的Fragment外,Action Bar也是一个重要的内容,Action Bar主要是用于代替传统的标题栏,对于Android平板设备来说屏幕更大它的标题使 ...
- DotNet加密方式解析--散列加密
没时间扯淡类,赶紧上车吧. 在现代社会中,信息安全对于每一个人都是至关重要的,例如我们的银行账户安全.支付宝和微信账户安全.以及邮箱等等,说到信息安全,那就必须得提到加密技术,至于加密的一些相关概念, ...
- CSS基础知识笔记(三)
继承 继承是一种规则,它允许样式不仅应用于某个特定html标签元素,而且应用于其后代.比如下面代码:如某种颜色应用于p标签,这个颜色设置不仅应用p标签,还应用于p标签中的所有子元素文本,这里子元素为s ...
- C#在foreach循环中修改字典等集合出错的处理
C#在foreach循环中修改字典等集合出错:System.InvalidOperationException: Collection was modified; enumeration operat ...
- iOS_SN_BlueTooth( 一)蓝牙相关基础知识
原文 http://www.cocoachina.com/ios/20150915/13454.html 作者:刘彦玮 蓝牙常见名称和缩写 MFI ======= make for ipad ,ip ...
- UILabel 的使用,属性详解
·UILable是iPhone界面最基本的控件,主要用来显示文本信息. ·常用属性和方法有: .创建 CGRect rect = CGRectMake(, , , ); UILabel *label ...
- c#字符串方法
作者: 常浩 staticvoid Main(string[] args) { string s =""; //(1)字符访问(下标访问s[i]) s ="ABCD&qu ...
- 求实现sql?
id name pid1 曾祖父 02 祖父 13 父亲 24 儿子 35 孙子 4备注:用一条数据库语句来解决查询结果:name1 name2 name3曾祖父 祖父 父亲曾祖父 父亲 儿子曾祖父 ...
- 库函数 Math
int abs( int num ); double fabs( double arg ); long labs( long num ); 函数返回num的绝对值 #include <mat ...
- VisualStudio中的编辑后期生成事件
在visual studio中加入项目文件,也就是引用外部文件,比如在tools\options中的show directions for中选择include files,我们需要引用项目(solut ...