Mercurial > hg > mood-conductor
view nodejs-server/server.js @ 54:c0b34039917a tip
Server: added an exposed function to log the start time of a performance (for log-to-audio sync)
author | Mathieu Barthet <mathieu.barthet@eecs.qmul.ac.uk> |
---|---|
date | Wed, 14 Oct 2015 19:20:08 +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");