Skip to content

Instantly share code, notes, and snippets.

@7gano
Created August 16, 2013 14:27
Show Gist options
  • Save 7gano/6250393 to your computer and use it in GitHub Desktop.
Save 7gano/6250393 to your computer and use it in GitHub Desktop.
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.get('/', routes.index);
app.get('/console', function(req, res){
console.log(req.query.log);
res.writeHead(200,{"Content-Type": "text/plain"});
res.end();
});
app.post('/console.log', function(req, res){
console.log(req.body);
res.writeHead(200,{"Content-Type": "text/plain"});
res.end();
});
app.get('/code', function(req, res){
res.writeHead(200,{"Content-Type": "text/plain"});
var f = function(){
return 1 + 1;
};
var code = f.toString();
code = '(' + code + ')()';
res.write(code);
res.end();
});
http.createServer(app).listen(app.get('port'), function(){
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment