Skip to content

Instantly share code, notes, and snippets.

@dot1q
Created March 28, 2020 04:58
Show Gist options
  • Select an option

  • Save dot1q/2f677d648f01dcacfa2e29f36a0e0982 to your computer and use it in GitHub Desktop.

Select an option

Save dot1q/2f677d648f01dcacfa2e29f36a0e0982 to your computer and use it in GitHub Desktop.
// include dependencies
import express from 'express';
import bodyParser from 'body-parser';
import fallback from 'express-history-api-fallback';
import path from 'path';
import Sign from './sign';
const app = express();
const sign = new Sign();
app.post('/sign', (req, res, next) => {
console.log(req.body);
if (sign.writeMessage(req.body.message, req.body.mode)) {
res.json('success');
} else {
res.status(500).send();
}
});
app.use('/', express.static(cwd));
app.use(fallback(path.join(cwd, 'index.html')));
app.listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment