server.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var fs = require('fs');
  2. var http = require('http');
  3. http.createServer(function(req, res) {
  4. switch (req.url) {
  5. case '/':
  6. case '/index.html': {
  7. res.writeHead(200, { 'Content-Type': 'text/html' });
  8. res.end(fs.readFileSync('index.html', 'utf8'));
  9. break;
  10. }
  11. case '/browser-source-map-support.js': {
  12. res.writeHead(200, { 'Content-Type': 'text/javascript' });
  13. res.end(fs.readFileSync('../browser-source-map-support.js', 'utf8'));
  14. break;
  15. }
  16. case '/script.js': {
  17. res.writeHead(200, { 'Content-Type': 'text/javascript', 'SourceMap': 'script-source-map.map' });
  18. res.end(fs.readFileSync('script.js', 'utf8'));
  19. break;
  20. }
  21. case '/script-source-map.map': {
  22. res.writeHead(200, { 'Content-Type': 'application/json' });
  23. res.end(fs.readFileSync('script.map', 'utf8'));
  24. break;
  25. }
  26. case '/header-test/script.coffee': {
  27. res.writeHead(200, { 'Content-Type': 'text/x-coffeescript' });
  28. res.end(fs.readFileSync('script.coffee', 'utf8'));
  29. break;
  30. }
  31. default: {
  32. res.writeHead(404, { 'Content-Type': 'text/html' });
  33. res.end('404 not found');
  34. break;
  35. }
  36. }
  37. }).listen(1337, '127.0.0.1');
  38. console.log('Server running at http://127.0.0.1:1337/');