// SPDX-License-Identifier: AGPL-3.0-only import express from "express" import { readFileSync } from "fs" import { readFile } from "fs/promises" import { join } from "path/posix" import pug from "pug" const app = express() const render_env = { commit: readFileSync(join(__dirname, "../.git/refs/heads/main")).toString().substr(0, 8) } app.disable('x-powered-by'); app.set("view engine", "pug") app.set("views", join(__dirname, "../views")) app.get("/", (req, res) => res.redirect("/about")) app.get("/about", (req, res) => res.render("about", render_env)) app.get("/projects", (req, res) => res.render("projects", render_env)) app.get("/contact", (req, res) => res.render("contact", render_env)) app.get("/links", (req, res) => res.render("links", render_env)) app.get("/licence", async (req, res) => { const content = (await readFile(join(__dirname, "../LICENCE"))).toString() res.type("text/plain").send(content) }) app.get("/favicon.ico", (req,res) => res.sendStatus(204)) // no content app.get("/robots.txt", (req,res) => { res.send("User-Agent: *\nDisallow: /\n") }) const PORT = parseInt(process.env.PORT ?? "8080") const HOST = process.env.HOST || "127.0.0.1" app.listen(PORT, HOST, () => console.log("aaaaa"))