mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 06:27:19 +01:00
initial commit
This commit is contained in:
28
index.js
Normal file
28
index.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const app = express();
|
||||
const templates = require('./templates');
|
||||
|
||||
app.use(bodyParser.json());
|
||||
|
||||
app.post('/generate/:template', (req, res) => {
|
||||
|
||||
const templateName = req.params.template;
|
||||
const options = req.body;
|
||||
|
||||
templates.get(templateName, options, (err, template) => {
|
||||
if (err) {
|
||||
console.error('Error:', err.code, 'for', req.url);
|
||||
res.sendStatus(500).end('Something went wrong, call Thomas');
|
||||
return;
|
||||
}
|
||||
|
||||
let result = template;
|
||||
|
||||
res.send(result);
|
||||
res.end();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
app.listen(5000);
|
||||
Reference in New Issue
Block a user