chnage static.js to run on node 0.8 as well
This commit is contained in:
parent
fa4b5d5474
commit
bbe951c73d
1 changed files with 11 additions and 7 deletions
18
static.js
18
static.js
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue