Create basic server
This commit is contained in:
parent
e362ddc784
commit
8f0660040a
2 changed files with 23 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -31,3 +31,5 @@ node_modules
|
|||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
site/
|
||||
|
|
21
server.js
Normal file
21
server.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const express = require('express');
|
||||
|
||||
const PORT = process.env.PORT;
|
||||
const serveDir = __dirname + '/site/';
|
||||
|
||||
const expressConfig = {
|
||||
dotfiles: 'deny',
|
||||
index: false,
|
||||
redirect: true
|
||||
};
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(
|
||||
express.static(serveDir, expressConfig)
|
||||
);
|
||||
|
||||
const server = app.listen(PORT, function () {
|
||||
const serverPort = server.address().port;
|
||||
console.log('Server started on port ' + serverPort);
|
||||
});
|
Reference in a new issue