-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·38 lines (30 loc) · 999 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
26
27
28
29
30
31
32
33
34
35
36
37
38
//Set up requirements
var express = require("express");
var logger = require('morgan');
var Request = require('request');
//Create an 'express' object
var app = express();
var port = process.env.PORT || 3000
//Some Middleware - log requests to the terminal console
app.use(logger('dev'));
//Set up the views directory
app.set("views", __dirname + '/views');
//Set EJS as templating language WITH html as an extension
app.engine('.html', require('ejs').__express);
app.set('view engine', 'html');
//Add connection to the public folder for css & js files
app.use(express.static(__dirname + '/public'));
app.use(function(req,res,next){
console.log('A Request Has Come In. Hooray!!!');
next();
});
//ROUTES
app.get("/", function(req, res){
res.render('index', {message: "Try adding a forward slash plus a word to the url"});
});
app.get("*", function(req, res){
res.send('Sorry, nothing doing here.');
});
// Start the server
app.listen(port);
console.log('Express started on port ' + port);