forked from carhartl/jquery-cookie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (20 loc) · 702 Bytes
/
server.js
File metadata and controls
24 lines (20 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var http = require('http'),
url = require('url'),
path = require('path'),
fs = require('fs');
http.createServer(function (request, response) {
var uri = url.parse(request.url).pathname,
filename = path.join(process.cwd(), uri);
fs.readFile(filename, 'binary', function (err, file) {
if (err) {
response.writeHead(500, { 'Content-Type': 'text/plain' });
response.write(err + '\n');
response.end();
return;
}
response.writeHead(200);
response.write(file, 'utf-8');
response.end();
});
}).listen(8124, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8124/');