-
Notifications
You must be signed in to change notification settings - Fork 2
/
node_init.js
39 lines (35 loc) · 1.1 KB
/
node_init.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
var util = require('util'),
http = require('http'),
fs = require('fs');
fs.readFile('./demo/blog-demo.html', function (err, content) {
if (err) {
throw err;
}
http.createServer(function(request, response) {
util.puts(request.url);
if(request.url === "/") {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(content);
response.end();
} else if(request.url === "/dist/jquery.smartify.min.js") {
fs.readFile('.' + request.url, function (err, content) {
if (err) {
throw err;
}
response.writeHeader(200, {"Content-Type": "text/javascript"});
response.write(content);
response.end();
});
} else if(request.url === "/demo/ajax-content.html") {
fs.readFile('.' + request.url, function (err, content) {
if (err) {
throw err;
}
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(content);
response.end();
});
}
}).listen(8080, '127.0.0.1');
util.puts('> Server running at http://127.0.0.1:8080/');
});