-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
39 lines (33 loc) · 1.05 KB
/
app.js
File metadata and controls
39 lines (33 loc) · 1.05 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
const http = require('http') //requesting for http
const fs = require('fs') //file handling for the libraries
const port = 3000
//personal note -- add more ports --
const server = http.createServer(function(req,res){
res.writeHead(200, {'Content-Type': 'text/html'}) //request status will parse request of html
fs.readFile('home.html', function(error, data){
if(error){ //validate errors
res.writeHead(404) //browser is unable to find file
res.write('Error: File Not Found')
}
else{
res.write(data) //data holds html file
}
})
fs.readFile('contact.html', function(error, data){
if(error){ //validate errors
res.writeHead(404) //browser is unable to find file
res.write('Error: File Not Found')
}
else{
res.write(data) //data holds html file
}
})
})
server.listen(port, function(error){
if(error){
console.log('hello is there a problem?', error)
}
else{
console.log('my ears are wide open on this port' + port)
}
})