Created
March 27, 2017 22:37
-
-
Save JonathanZWhite/83c1db592470bb33d40b956baf00097c 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
var express = require('express'); | |
var path = require('path'); | |
var bodyParser = require('body-parser'); | |
var subscribe = require('./subscribe'); | |
var app = new express(); | |
var port = 8000; | |
// middleware | |
app.use(bodyParser.json()); | |
app.use(cors()); | |
app.get('/api/book', function(req, res) { | |
var name = req.body.name; | |
var service = req.body.service; | |
// ... etc | |
subscribe.send(name, service); | |
}); | |
// static | |
app.use(function(req, res) { | |
res.sendFile(__dirname + '/src/index.html'); | |
}); | |
app.listen(port, function(error) { | |
if (error) { | |
console.error(error); | |
} else { | |
console.info("==> 🌎 Listening on port 8000. Open up http://localhost:%s/ in your browser.", 8000, 8000); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment