-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
38 lines (30 loc) · 868 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const express = require('express')
const app = express()
const bodyParser = require('body-parser');
app.use(bodyParser.json());
const Meme = require('./meme');
app.route('/memes/expandingbrain').get((req, res) => {
res.send("Expanding Brain endpoint");
});
app.route('/memes/expandingbrain').post(async (req, res) => {
let body = req.body;
let expandingBrainMeme = new Meme(
'expand.jpg',
[
[30, 100],
[30, 400],
[30, 700],
[30, 1000]
],
370
)
try {
let imageData = await expandingBrainMeme.create(body.captions);
res.set('Content-Type', 'image/jpeg');
res.end(imageData);
} catch (e) {
res.status = 400;
res.send(e);
}
});
app.listen(process.env.PORT || 3000, () => console.log("Demo listening on port 3000"));