-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (18 loc) · 861 Bytes
/
Copy pathserver.js
File metadata and controls
24 lines (18 loc) · 861 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
// We first require our express package
var express = require('express');
// This package exports the function to create an express instance:
var app = express();
// This middleware will activate for every request we make to
// any path starting with /assets;
// it will check the 'static' folder for matching files
app.use('/assets', express.static('static'));
// Setup your routes here!
app.get("/", function (request, response) {
// We have to pass a second parameter to specify the root directory
// __dirname is a global variable representing the file directory you are currently in
response.sendFile("./pages/index.html", { root: __dirname });
});
// We can now navigate to localhost:3000
app.listen(3000, function () {
console.log('Your server is now listening on port 3000! Navigate to http://localhost:3000 to access it');
});