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的更多相关文章

  1. [Hapi.js] View engines

    View engines, or template engines, allow you to maintain a clean separation between your presentatio ...

  2. [Hapi.js] Managing State with Cookies

    hapi has built-in support for parsing cookies from a request headers, and writing cookies to a respo ...

  3. [Hapi.js] Request Validation with Joi

    hapi supports request validation out of the box using the joi module. Request path parameters, paylo ...

  4. [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 ...

  5. [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 ...

  6. [Hapi.js] POST and PUT request payloads

    hapi makes handling POST and PUT payloads easy by buffering and parsing them automatically without r ...

  7. [Hapi.js] Serving static files

    hapi does not support serving static files out of the box. Instead it relies on a module called Iner ...

  8. [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 ...

  9. [Hapi.js] Route parameters

    Routing is a fundamental aspect of any framework. In this lesson, you'll learn how to use path param ...

随机推荐

  1. Hadoop Failed to set permissions of path

    在Eclipse里面写了个測试程序:把HDFS中的数据批量导入到HBase中 写好后,在本地測试遇到了例如以下问题: 14/04/21 16:49:53 WARN util.NativeCodeLoa ...

  2. Angular单页应用&AngularJS内部实现原理

    回顾 自定义指令 登录后获取登录信息session 首先在登录验证的时候保存一个user 在学生管理页面中运用ajax调用获取到登录的用户信息 对注销按钮添加点击事件:调用ajax在表现层给user赋 ...

  3. (转)CSS 禁止浏览器滚动条的方法

    1.完全隐藏 在里加入scroll="no",可隐藏滚动条:    这个我用的时候完全没效果,不知道是什么原因!不过好多人说这么用可以,大概是用的位置不一样吧   2.在不需要时隐 ...

  4. performSelector的方法

    在此我对performSelector系列方法进行了总结 1. - (id)performSelector:(SEL)aSelector; - (id)performSelector:(SEL)aSe ...

  5. 访问MySQL数据库时,报“找不到请求的 .net Framework 数据提供程序。可能没有安装。”的解决方案

    最近开发了一个系统,在测试环境上进行部署(win7环境)并测试,没有发现问题:但是把系统部署到win Server2008R2上之后,部分页面就报“找不到请求的 .net Framework 数据提供 ...

  6. 记一次令人发狂的 bug Eclipse 开不开 tomcat 7.0

    改项目,结果发现以前的项目也出了问题,就删除了系统用户下面workplace里的文件夹,结果,eclipse被清空,重新添加项目,发现一堆bug; 最让我崩溃的是,用tomcat 7.0跑项目,反复出 ...

  7. HDU 4612 (13年多校第二场1002)无向图缩点,有重边

    这道题是多校的题,比赛的时候是一道纷纷水过的板刷题. 题意:给你一些无向边,只加一条边,使该图的桥最少,然后输出最少的桥. 思路:当时大致想到思路了,就是缩点之后找出最长的链,然后用总的桥数减去链上的 ...

  8. 关于bootStrapdialog 学习心得

    在用play这个框架做项目的时候,我们的背景以及一些插件用的都是 bootStrap3.0的JS以及CSS 这次用到的bootStrapdialog 所需要演示的效果 就是 在一个网页系统里,  当你 ...

  9. 帝国cms7.0整合百度编辑器ueditor教程

    帝国cms7.0整合百度编辑器ueditor教程开始 1.根据自己使用的帝国cms版本编码下载对应的ueditor版本 下载地址 http://ueditor.baidu.com/website/do ...

  10. 一个人的旅行--hdu2066

    一个人的旅行 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...