Created
February 27, 2013 14:51
-
-
Save SE7ENSKY/5048448 to your computer and use it in GitHub Desktop.
Simple http server, which logs all requests to stdout.
This file contains hidden or 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
host = process.env.HOST or '0.0.0.0' | |
port = process.env.PORT or 3000 | |
http = require 'http' | |
server = http.createServer (req, res) -> | |
console.log "\n#{req.method} #{req.url}" | |
console.dir req.headers | |
req.setEncoding 'utf8' | |
req.on 'data', (data) -> | |
console.log data | |
res.writeHead 200, | |
'Content-Type': 'text/plain' | |
res.end "ok" | |
server.on 'listening', -> | |
console.log "verboser listening at #{host}:#{port}" | |
server.listen port, host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment