-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
29 lines (23 loc) · 970 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
// Node npm packages requires
var express = require("express");
var bodyParser = require("body-parser");
var http = require("http");
// Server variables
var app = express();
var httpPort = process.env.PORT || 8080;
// Serve up the public folder to the site
app.use(express.static(__dirname + "/public"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended : false}));
// Set up view engine to be html - render html
app.set('view engine', 'ejs'); // set up ejs for templating
app.use(express.static(__dirname + '/views'));
// Require the necessary express routes and use them
app.use("/", require("./routes/index.js"));
app.use("/login", require("./routes/login.js"));
app.use("/register", require("./routes/register.js"));
app.use("/profile", require("./routes/profile.js"));
// Start up the server
var httpServer = http.createServer(app);
httpServer.listen(httpPort);
console.log("Magic happens on port " + httpPort);