forked from cs4241-19a/a1-gettingstarted
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (31 loc) · 878 Bytes
/
server.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
const http = require('http'),
fs = require('fs'),
port = 3000
const server = http.createServer( function( request,response ) {
switch( request.url ) {
case '/':
sendFile( response, 'index.html' )
break
case '/index.html':
sendFile( response, 'index.html' )
break
case '/exStyles.css':
sendFile( response, 'exStyles.css' )
break
case '/res/HunterProfile.jpg':
sendFile( response, '/res/HunterProfile.jpg' )
break
case '/res/HunterProfile2.jpg':
sendFile( response, '/res/HunterProfile2.jpg' )
break
default:
response.end( '404 Error: File Not Found' )
}
})
server.listen( process.env.PORT || port )
const sendFile = function( response, filename ) {
fs.readFile( filename, function( err, content ) {
File = content
response.end( content, 'utf-8' )
})
}