view nodejs-server/server.js @ 20:e4790d4419c1

iphone fix
author mgeorgi
date Fri, 22 Jun 2012 15:39:55 +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");