Mercurial > hg > mood-conductor
view nodejs-server/server.js @ 0:89a05584e39e
initial commit of mood conductor stuff
author | gyorgyf |
---|---|
date | Sat, 16 Jun 2012 20:31:41 +0100 |
parents | |
children | 9d2f4e6a3f36 |
line wrap: on
line source
var http = require('http'); var fs = require('fs'); http.createServer(function (req, res) { console.log(req.url); switch (req.url) { case '/mood': res.end("{status:'ok'}"); res.writeHead(200, {'Content-Type': 'application/json'}); break; case '/moods.csv': res.end(fs.readFileSync("moods.csv")); res.writeHead(200, {'Content-Type': 'text/plain'}); break; case '/app.js': res.end(fs.readFileSync("app.js")); res.writeHead(200, {'Content-Type': 'text/javascript'}); break; default: res.end(fs.readFileSync("index.html")); res.writeHead(404, {'Content-Type': 'text/plain'}); } }).listen(3000, "127.0.0.1");