chnage static.js to run on node 0.8 as well

This commit is contained in:
nightwing 2012-07-10 10:06:56 +04:00
commit bbe951c73d

View file

@ -1,18 +1,22 @@
#!/usr/bin/env node
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
mime = require("mime"),
port = process.env.PORT || 8888;
var http = require("http")
, path = require("path")
, mime = require("mime")
, url = require("url")
, fs = require("fs")
, port = process.env.PORT || 8888;
// compatibility with node 0.6
if (!fs.exists)
fs.exists = path.exists;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
path.exists(filename, function(exists) {
fs.exists(filename, function(exists) {
if(!exists) {
response.writeHead(404, {"Content-Type": "text/plain"});
response.write("404 Not Found\n");