-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathns_old.js
More file actions
45 lines (35 loc) · 1.04 KB
/
ns_old.js
File metadata and controls
45 lines (35 loc) · 1.04 KB
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
45
var http = require('http'),
url = require('url'),
path = require('path'),
fs = require('fs'),
sys = require('sys'),
net = require('net');
/*
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('najam sikander awan \n is great');
}).listen(8124, "192.168.2.101"); */
hserver = http.createServer(function(request , response){
var uri = url.parse(request.url).pathname;
var filename = path.join(process.cwd(), uri);
path.exists(filename, function(ex){
if(!ex){
response.writeHead(404, {'Content-Type':'text/plain'});
response.end("cant find it ....");
return;
}
fs.readFile(filename, "binary", function(err , data){
if(err){
response.writeHead(500, {'Content-Type': 'text/plain'});
response.write('404');
response.end("nahi mili file");
return;
}
response.writeHead(200);
response.write(data, "binary");
response.end("checking ");
});
});
});
hserver.listen(80, "192.168.1.9");
console.log('Server running at http://127.0.0.1:8124/');