Mercurial > hg > mood-conductor
view nodejs-server/server.js @ 38:b17a5b6f74a4
Added Last fm curated list of tags
| author | Mathieu Barthet <mathieu.barthet@eecs.qmul.ac.uk> |
|---|---|
| date | Sun, 03 May 2015 18:45:24 +0100 |
| parents | c84bcf573b31 |
| children |
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(80, "0.0.0.0");
