initial upload
This commit is contained in:
parent
b2a512f7fe
commit
48ae5e89aa
30 changed files with 1293 additions and 0 deletions
37
master.mjs
Normal file
37
master.mjs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
// Load WebServer
|
||||
import express from "express";
|
||||
import { router } from "express-file-routing"
|
||||
|
||||
// Load Templating Engine
|
||||
import Nunjucks from "nunjucks";
|
||||
|
||||
// Initialize WebServer
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
// Middleware, um CORS zu aktivieren
|
||||
app.use((req, res, next) => {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
|
||||
res.header("Access-Control-Allow-Headers", "Content-Type, Authorization");
|
||||
next();
|
||||
});
|
||||
|
||||
// Configure Templating Engine
|
||||
Nunjucks.configure('./', {
|
||||
autoescape: false,
|
||||
express: app,
|
||||
noCache: true
|
||||
});
|
||||
|
||||
// Mount Middlewares to WebServer
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded());
|
||||
app.use(express.static('./assets/'))
|
||||
app.use("/", await router());
|
||||
|
||||
// Server starten
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is listening on port ${port}`);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue