forked from tuanht0101/master-OCR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (25 loc) · 874 Bytes
/
Copy pathserver.js
File metadata and controls
33 lines (25 loc) · 874 Bytes
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
const express = require('express');
const next = require('next');
const path = require('path');
const bodyParser = require('body-parser');
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dir: '.', dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
const server = express();
server.use('/images', express.static(path.join(__dirname, 'images'), {
maxAge: dev ? '0' : '365d'
}));
server.use(bodyParser.json());
server.get('*', (req, res) => {
return handle(req, res)
});
// server.get('/model/:id', (req, res) => {
// return app.render(req, res, '/model', { id: req.params.id })
// })
const PORT = process.env.PORT || 4001;
server.listen(PORT, (err) => {
if (err) throw err
// console.log(`> Read on http://localhost:${PORT}`)
});
})