-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·28 lines (21 loc) · 831 Bytes
/
Copy pathserver.js
File metadata and controls
executable file
·28 lines (21 loc) · 831 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
var express = require('express');
var localhost = express();
var dotenv = require('dotenv');
var bodyParser = require('body-parser');
//*** Configuration ***//
// Set your main file here
var mainFile = '/index.html';
// Set your available localhost port here
var localhostPort = 9000;
// Get cofiguration file from .env (if needed)
dotenv.load();
// Parse incoming request bodies in a middleware before your handlers (if needed)
localhost.use(bodyParser.json());
// Start the server and manage a mod rewrite that forward to specified page
localhost.use(express.static(__dirname));
localhost.get(/.*/, function (req, res) {
res.sendFile(__dirname + mainFile);
});
localhost.listen(process.env.PORT || localhostPort, function () {
console.log("Start surfing at localhost:%d", (process.env.PORT || localhostPort));
});