-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js~
executable file
·34 lines (28 loc) · 930 Bytes
/
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
//include our modules
var sys = require('sys');
var http = require('http');
var url = require('url');
//require custom dispatcher
var dispatcher = require('dispatcher.js');
console.log('Starting server @ http://127.0.0.1:54920/');
http.createServer(function (req, res) {
//wrap calls in a try catch
//or the node js server will crash upon any code errors
try {
//pipe some details to the node console
console.log('Incoming Request from: ' +
req.connection.remoteAddress +
' for href: ' + url.parse(req.url).href
);
//dispatch our request
dispatcher.dispatch(req, res);
} catch (err) {
//handle errors gracefully
sys.puts(err);
res.writeHead(500);
res.end('Internal Server Error');
}
}).listen(54920, "127.0.0.1", function() {
//runs when our server is created
console.log('Server running at http://127.0.0.1:54920/');
});