-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (26 loc) · 1.13 KB
/
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
// var http = require("http");
// //This is the callback method, is called every time a user makes a request
// //Request object has info about their request, response object is what we send back to them
// function onRequest(request, response) {
// console.log("A user made a request" + request.url);
// response.writeHead(200, {"Content-Type": "text/plain"});
// response.write("I am a simple Node server!");
// response.end();
// }
// //Create a server and listen for requests on this port
// http.createServer(onRequest).listen(8888);
// console.log("Server is now running...");
// //Now open Chrome and go to http://localhost:8888
// //Saying that user made request twice because browser also makes a request for the favicon
// grab the packages we need
var express = require('express');
var app = express();
var port = process.env.PORT || 8080;
// routes will go here
app.use(express.static(__dirname + "/Project/"));
// start the server
app.get('/', function(req, res){
res.sendfile('Html/Home.html', { root: __dirname + "/Project/" } );
});
app.listen(port);
console.log('Server started! At http://localhost:' + port);