Skip to content

Instantly share code, notes, and snippets.

@cheng470
Last active August 29, 2015 14:08
Show Gist options
  • Save cheng470/cbbc636c64ed74232ba6 to your computer and use it in GitHub Desktop.
Save cheng470/cbbc636c64ed74232ba6 to your computer and use it in GitHub Desktop.
express 框架的 hello world 例子
var express = require('express');
var app = express();
app.get('/hello.txt', function (req, res) {
res.send('Hello World');
});
var server = app.listen(3000);
// 浏览器访问 http://127.0.0.1:3000/hello.txt
// 响应报文
/*
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 11
ETag: W/"b-4a17b156"
Date: Fri, 07 Nov 2014 14:11:43 GMT
Connection: keep-alive
Hello World
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment