Skip to content

Instantly share code, notes, and snippets.

@heronyang
Created June 24, 2019 01:06
Show Gist options
  • Save heronyang/d0d28f812b4ec1751d6b21cd569f1971 to your computer and use it in GitHub Desktop.
Save heronyang/d0d28f812b4ec1751d6b21cd569f1971 to your computer and use it in GitHub Desktop.
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