Created
October 27, 2017 13:17
-
-
Save TechNinjaWeb/3b6a7636714d6bebbbb54bd90feb369c to your computer and use it in GitHub Desktop.
Basic Express Server
This file contains 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 fs = require('fs') | |
const port = process.env.PORT || 5000 | |
const express = require('express') | |
const app = express() | |
const http = require('http') | |
const bodyParser = require('body-parser') | |
const server = http.createServer(app) | |
const _ = require('lodash') | |
// Express App setup | |
app.use(express.static(__dirname)) | |
app.use(bodyParser.json()) | |
// Catch the test route | |
app.all(['/test'], function(req, res, next) { | |
res.send('testing') | |
}) | |
// Catch all other routes | |
app.all(['*'], function(req, res, next){ | |
res.send('ok') | |
}) | |
// Begin server | |
server.listen(port, () => console.log(`App running on localhost:${port}`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment