Mercurial > hg > mood-conductor
view nodejs-server/server.js @ 10:63cc59d5b665
send on mouse release
author | mgeorgi |
---|---|
date | Fri, 22 Jun 2012 11:01:34 +0100 |
parents | 9d2f4e6a3f36 |
children | c84bcf573b31 |
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 '/colors.txt': res.end(fs.readFileSync("colors.txt")); res.writeHead(200, {'Content-Type': 'text/plain'}); 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, "0.0.0.0");