-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsampleServer.js
More file actions
35 lines (27 loc) · 905 Bytes
/
Copy pathsampleServer.js
File metadata and controls
35 lines (27 loc) · 905 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
25
26
27
28
29
30
31
32
33
34
35
var http = require('http')
var fs = require('fs')
var url = require('url')
http.createServer((req,res)=>{
var q = url.parse(req.url,true);
if(q.pathname === '/'){
fs.readFile('./index.html',(err,data)=>{
res.writeHead(200,{'Content-Type':'text/html'})
res.write(data)
res.end()
})
}else if(q.pathname==='/signup'){
fs.readFile('./signup.html',(err,data)=>{
res.writeHead(200,{"Content-Type":"text/html"})
res.write(data)
res.end()
})
}else if(q.pathname === '/signupaction'){
res.writeHead(200,{"Content-Type":"text/html"})
res.write('<h1>'+q.query.fname+'</h1>')
res.end()
}else{
res.writeHead(404,{"Content-Type":"text/html"})
res.write("error")
res.end()
}
}).listen(7000,()=>console.log("Server started"))