-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (29 loc) · 967 Bytes
/
server.js
File metadata and controls
34 lines (29 loc) · 967 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
25
26
27
28
29
30
31
32
33
34
var express = require("express");
var app = express();
var fs = require('fs');
app.engine('html', function (filePath, options, callback) {
fs.readFile(filePath, function (err, content) {
if (err) return callback(new Error(err));
var rendered = content.toString();
return callback(null, rendered);
});
});
app.set('views', './dist');
app.set('view engine', 'html');
app.use("/scripts", express.static("dist/scripts"));
app.use("/styles", express.static("dist/styles"));
app.use("/images", express.static("dist/images"));
app.set('trust proxy', true);
app.disable("x-powered-by");
app.get("/", function(req, res){
res.render("index");
});
app.get("/favicon.ico", function(req, res){
res.sendFile(__dirname + "/dist/favicon.ico");
});
app.get("/humans.txt", function(req, res){
res.sendFile(__dirname + "/dist/humans.txt");
});
app.listen((process.env.PORT || 3000), function(){
console.log("Express on %s", (process.env.PORT || 3000));
});