1 |
|
2 | var express = require('express');
|
3 | var path = require('path');
|
4 |
|
5 | var app = express()
|
6 | var cors = require('cors');
|
7 |
|
8 | var bodyParser = require('body-parser');
|
9 |
|
10 | app.use(cors());
|
11 | app.use(bodyParser.json());
|
12 | app.use(bodyParser.urlencoded({extended:true}));
|
13 |
|
14 |
|
15 | const pageName = process.env.PAGE;
|
16 | const moduleName = process.env.MODULE;
|
17 | const webPath = process.env.WEBPATH;
|
18 |
|
19 |
|
20 | console.log('static path,', webPath);
|
21 | app.use(express.static(webPath));
|
22 |
|
23 |
|
24 | console.log('env page,module webPath===>',pageName,moduleName,webPath);
|
25 |
|
26 | app.post('/createPage', function(req, res, next) {
|
27 |
|
28 | console.log("received data", req.body);
|
29 | require(path.resolve(__dirname, '../../lib/page-creator.js'))(req.body.params,pageName,moduleName);
|
30 | res.json(req.body);
|
31 | });
|
32 |
|
33 | const port = 3000
|
34 | app.listen(port, () => {
|
35 | console.log(`Example app listening at http://localhost:${port}`)
|
36 | })
|