1 | let http = require('http')
|
2 | const fs = require('fs')
|
3 | const path = require('path')
|
4 | let querystring = require('querystring')
|
5 | const bodyHandle = require('./lib/page')
|
6 |
|
7 | const corePath = path.join(__dirname, 'core')
|
8 | http.createServer(function (req, res) {
|
9 |
|
10 | let body = ""
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | req.on('data', function (chunk) {
|
17 | body += chunk;
|
18 |
|
19 | })
|
20 |
|
21 |
|
22 | req.on('end', function () {
|
23 | console.log(body)
|
24 |
|
25 | const dom = bodyHandle(body, {
|
26 | "root": "/src",
|
27 | "entry": "servertemple0",
|
28 | "headFolder": "head",
|
29 | "outFolder": "dist",
|
30 | "autoPack": true,
|
31 | "minifyCss": false,
|
32 | "minifyJs": false,
|
33 | "pageFolder": "page"
|
34 | })
|
35 |
|
36 |
|
37 |
|
38 | let coreScript = fs.readFileSync(path.join(corePath, 'main.js'), 'utf8')
|
39 | if (dom.isOnePage) {
|
40 |
|
41 | coreScript += fs.readFileSync(path.join(corePath, 'SinglePage.js'), 'utf8')
|
42 | } else {
|
43 |
|
44 | coreScript += fs.readFileSync(path.join(corePath, 'MultiPage.js'), 'utf8')
|
45 | }
|
46 |
|
47 | coreScript += fs.readFileSync(path.join(corePath, 'animation.js'), 'utf8')
|
48 |
|
49 | dom.script = coreScript + dom.script
|
50 |
|
51 | res.setHeader('Access-Control-Allow-Origin', '*')
|
52 | res.write(JSON.stringify(dom))
|
53 |
|
54 | res.end()
|
55 | })
|
56 | }).listen(3000) |
\ | No newline at end of file |