Created
July 24, 2012 01:20
-
-
Save adamvr/3167323 to your computer and use it in GitHub Desktop.
HTTP Agent and request logger
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
| node_modules |
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
| express = require 'express' | |
| util = require 'util' | |
| app = express() | |
| port = process.env['PORT'] or 3000 | |
| host = '0.0.0.0' | |
| reqs = [] | |
| app.set 'view engine', 'jade' | |
| app.set 'views', '.' | |
| app.get '/', (req, res) -> | |
| res.render 'index', reqs: reqs.map (m) -> util.inspect m | |
| app.all '*', (req, res) -> | |
| reqs.push req | |
| app.listen port, host |
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
| html | |
| head | |
| title Requests | |
| body | |
| h1 Requests | |
| ul | |
| each req in reqs | |
| li #{req} |
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
| { | |
| "name": "echoer", | |
| "version": "0.0.1", | |
| "description": "Dumps requests", | |
| "main": "app.coffee", | |
| "private": true, | |
| "dependencies": { | |
| "express": "~3.0.0", | |
| "jade": "~0.26.3", | |
| "coffee-script": "~1.3.3" | |
| }, | |
| "scripts": { | |
| "start": "coffee app.coffee" | |
| }, | |
| "repository": { | |
| "type": "git", | |
| "url": "git@gist.github.com:3167323.git" | |
| }, | |
| "engines": { | |
| "node": "~0.6.0" | |
| }, | |
| "author": "Adam Rudd", | |
| "license": "BSD" | |
| } |
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
| web: coffee app.coffee |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment