Skip to content

Instantly share code, notes, and snippets.

@kuronekomichael
Created September 6, 2013 15:06
Show Gist options
  • Save kuronekomichael/6465127 to your computer and use it in GitHub Desktop.
Save kuronekomichael/6465127 to your computer and use it in GitHub Desktop.
expressで静的なJSONを返すだけのサーバを極力小さいコードで書いた感じ $ npm init $ npm install express --save-dev $ npm start
var express = require('express'),
port = 48172,
ret = { name:'hello', value:'world' };
express().get('/', function(req, res) {
res.contentType('application/json').send(JSON.stringify(ret));
}).listen(port, function() {
console.log("express server on localhost:%d", this.address().port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment