Web Application
npx kaelum create my-website --template webcd my-website && npm installapp.js
Section titled “app.js”const kaelum = require("kaelum");const routes = require("./routes");const app = kaelum();
app.setConfig({ static: "public", logs: "dev", port: 3000, views: { engine: "ejs", path: "./views" },});
routes(app);app.useErrorHandler();app.start();routes.js
Section titled “routes.js”module.exports = (app) => { app.addRoute("/", { get: (req, res) => res.render("index", { title: "Home" }), });
app.addRoute("/about", { get: (req, res) => res.render("about", { title: "About" }), });
app.addRoute("/contact", { get: (req, res) => res.render("contact", { title: "Contact" }), post: (req, res) => { console.log("Form:", req.body); res.redirect("/contact?sent=true"); }, });};views/index.ejs
Section titled “views/index.ejs”<!DOCTYPE html><html><head> <title><%= title %></title> <link rel="stylesheet" href="/style.css"></head><body> <h1><%= title %></h1> <nav> <a href="/">Home</a> | <a href="/about">About</a> | <a href="/contact">Contact</a> </nav></body></html>