33 lines
543 B
JavaScript
33 lines
543 B
JavaScript
|
import express from 'express'
|
||
|
import njk from 'nunjucks'
|
||
|
import fs from 'fs'
|
||
|
|
||
|
|
||
|
const ConfigFile = await fs.readFileSync('./config.json')
|
||
|
const Config = JSON.parse(ConfigFile)
|
||
|
|
||
|
|
||
|
|
||
|
const Server = express()
|
||
|
|
||
|
Server.use('/assets', express.static(Config.assetsDir))
|
||
|
|
||
|
njk.configure(
|
||
|
Config.contentDir,
|
||
|
{
|
||
|
autoescape: true,
|
||
|
express: Server
|
||
|
}
|
||
|
)
|
||
|
|
||
|
Server.get('*', (req, res) => {
|
||
|
res.send(req.url)
|
||
|
})
|
||
|
|
||
|
|
||
|
Server.listen(
|
||
|
Config.serverPort,
|
||
|
() => {
|
||
|
console.log(`Started server on ${Config.serverPort}.`)
|
||
|
}
|
||
|
)
|