-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (32 loc) · 1.09 KB
/
index.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
37
38
39
40
41
42
43
44
//2024-05-04 copyright (c) falsefox.dev
const express = require('express')
const app = express()
const fs = require("fs")
const path = require("path");
const {
exec
} = require("child_process")
//Compile to build
const port = 3000
app.use('/public', express.static('public'));
app.use('/styles', express.static('styles'));
function test(req, res, next) {
exec(`spawn-fcgi -n -a 127.0.0.1 -p 9000 ./build/pages${req.originalUrl}/index`, function (err, stdout, stderr) {
if (err) {
exec(`spawn-fcgi -n -a 127.0.0.1 -p 9000 ./build/pages/404`, function (err, stdout2, stderr) {
if (err) {
console.error("----------------------------\n Error occured while fetching 404 page, are your paths set correctly?\n----------------------------\n")
console.error(err)
}
res.send(stdout2)
})
console.log(err)
} else {
res.send(stdout)
}
})
}
app.get("/*", test);
app.listen(port, () => {
console.log(`Webserver is live at localhost:${port}!`)
})