[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 ...
随机推荐
- WebSphere配置数据库连接池
通过WebSphere配置数据库连接池一共需要三项: 1.配置连接驱动,在这里叫:JDBC提供程序; 2.配置数据库连接池,在这里叫:配置数据源; 3.配置数据库登录帐号,密码,在这里 ...
- Android-IM架构设计
###1. 架构总览 ###2. 模块介绍 ####2.1 协议封装与任务流程 #####1) 协议与任务的封装 a. 协议有协议头(协议头因为格式相同,被抽象出来)和协议体组成,协议有两类:请求协议 ...
- iOS程序的加载过程
1.执行main函数2.执行UIApplicationMain函数1> 创建一个UIApplication对象(UIApplication是整个程序的象征)一个应用只有一个application ...
- 文本输入框的两种div+css的写法
1.扁平化的设计风格.--淘宝 直接使用input.对其设置height.padding.使鼠标居中又不会占满输入框. 2.背景是图片的设计.--百度 试用span将input包裹 ...
- asp Eval()函数的一些使用总结
一.函数的原型: Eval(string s); s可以是变量,表达式,语句: 二.使用: 1.s为变量时,返回该变量的值,如:string s = "sss";Eval(s);/ ...
- Sqlserver in 实现 参数化查询 XML类型
原文: http://www.cnblogs.com/tangruixin/archive/2012/04/23/2465917.html 1:如果参数是int类型: declare @a xmlse ...
- asp.net中的主题
用了更方便,在.net网站上,右键,选择添加主题,然后命一个名子,如果,有四个主题, 只需要在web.config的page节里加上styleSheetTheme="Red",就会 ...
- win7_64位主机装虚机Linux系统(VMware Workstation10+CentOS6.5)详细步骤图文讲解
第一步:创建新的虚拟机 第二步:选择“典型”安装 第三步:选择映像文件安装—浏览选择iso文件 第四步:选择稍后安装操作系统 第五步:系统选择Linux,版本选择centOS64位 第六步:虚拟机名称 ...
- Js 时间间隔计算(间隔天数)
function GetDateDiff(startDate,endDate) { var startTime = new Date(Date.parse(startDate.replac ...
- JavaScript优化参考
最近在为管理系统的网站做点优化,压缩都用了工具,就没太多可以讨论的. 主要还是代码上的精简和优化.稍微整理一下,顺便做点测试. 这里先贴上项目中用来替代iFrame的Ajax处理的局部代码,本人比较讨 ...