forked from cmsc389T-fall2023/cmsc389T-web-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
25 lines (19 loc) · 755 Bytes
/
app.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
#!/usr/bin/nodejs
// -------------- load packages -------------- //
var express = require('express');
var app = express();
var path = require('path');
app.set('port', process.env.PORT || 8080 );
app.use('/js', express.static(path.join(__dirname, 'js')))
app.use('/css', express.static(path.join(__dirname, 'css')))
app.use('/assets', express.static(path.join(__dirname, 'assets')))
app.get('/', function(req, res){
res.sendFile(path.join(__dirname,'index.html'))
});
app.get('/:page',function(req,res){
console.log("Error Page Not Found");
res.send({"Message": "Error Page Not Found", "Code": "404"});
});
var listener = app.listen(app.get('port'), function() {
console.log( 'Express server started on port: '+listener.address().port );
});