Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JonathanZWhite/83c1db592470bb33d40b956baf00097c to your computer and use it in GitHub Desktop.
Save JonathanZWhite/83c1db592470bb33d40b956baf00097c to your computer and use it in GitHub Desktop.
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