Created
June 24, 2019 01:06
-
-
Save heronyang/d0d28f812b4ec1751d6b21cd569f1971 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dotenv = require('dotenv'); | |
const express = require('express'); | |
// Loads environment variables | |
dotenv.config(); | |
const hostname = process.env.HOSTNAME; | |
const port = process.env.PORT; | |
const gmap_api_key = process.env.GMAP_API_KEY; | |
// Setups the server. | |
var app = express(); | |
app.set('view engine', 'ejs'); | |
// Sets files under static/ as static files. | |
app.use(express.static('static')); | |
// Serves homepage with index.html. | |
app.get('/', (req, res) => { | |
res.render('index', { gmap_api_key: gmap_api_key }) | |
}); | |
// Entry point for starting the server. | |
function start_server() { | |
app.listen(port); | |
console.log('Running server on port ' + port); | |
} | |
start_server(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment