-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
44 lines (37 loc) · 1.16 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var express = require('express'),
app = express.createServer()
// Reference
// http://expressjs.com/guide.html
// https://github.com/spadin/simple-express-static-server
// http://devcenter.heroku.com/articles/node-js
// Configuration
app.configure(function(){
app.use(express.static(__dirname + '/public'));
app.use(express.bodyParser());
app.use(express.methodOverride());
// LESS Support
//app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] }));
// Template-enabled html view (by jade)
// http://stackoverflow.com/questions/4529586/render-basic-html-view-in-node-js-express
//app.set('views', __dirname + '/app/views');
//app.register('.html', require('jade'));
//Error Handling
app.use(express.logger());
app.use(express.errorHandler({
dumpExceptions: true,
showStack: true
}));
//Setup the Route, you are almost done
app.use(app.router);
});
app.get('/', function(req, res){
//Apache-like static index.html (public/index.html)
res.redirect("/index.html");
//Or render from view
//res.render("index.html")
});
//Heroku
var port = process.env.PORT || 3000;
app.listen(port, function() {
console.log("Listening on " + port);
});