Last active
April 29, 2016 04:32
-
-
Save acidsound/4414368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('http').createServer((q,r)->require('fs').readFile(process.cwd()+q.url,(e,d)->r.end if e? then JSON.stringify(e) else d.toString())).listen 3000 or process.env.PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http=require('http'); | |
var fs=require('fs'); | |
http.createServer(function(req, res) { | |
console.log( | |
"["+Date.now()+"]"+ | |
"METHOD:"+req.method+ | |
" | URL:"+req.url | |
); | |
fs.readFile(req.url==='/' && 'index.html' || process.cwd()+req.url, function(err, data) { | |
res.write(err && JSON.stringify(err) || data.toString()); | |
res.end(); | |
}); | |
}).listen(process.env.PORT or 3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'http' | |
.createServer (q,r) -> | |
console.log "[#{new Date().toISOString()}]#{q.method}: #{q.url}" | |
require('fs').readFile process.cwd()+q.url, (e,d)-> | |
r.end if e? then JSON.stringify(e) else d.toString() | |
.listen process.env.PORT or 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('http').createServer((q,r)=> { | |
console.log(`[${new Date().toISOString()}]${q.method}: ${q.url}`); | |
require('fs').readFile(process.cwd()+q.url, (e,d)=> { | |
r.end(e && JSON.stringify(e) || d.toString()); | |
}); | |
}).listen(process.env.PORT || 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment