Last active
January 14, 2024 19:05
-
-
Save tausiq2003/77c5ce26da3f2bea7510f9001e22700d to your computer and use it in GitHub Desktop.
This is only.js template, it creates dynamic pages without HTML and CSS files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const { JSDOM } = require("jsdom"); | |
const app = express(); | |
const port = 6969; | |
app.use(express.static("assets")); | |
app.get("/", (req, res) => { | |
const dom = new JSDOM(`<!DOCTYPE html>`); | |
const doc = dom.window.document; | |
// Use doc instead of document | |
// Build here | |
// More building.... | |
// ... | |
// ... | |
// Before using this install express and jsdom | |
// npm install -S express jsdom | |
res.writeHead(200, { "Content-Type": "text/html" }); | |
res.end(dom.serialize()); | |
}); | |
app.listen(port, () => { | |
console.log(`onlyjs is available at ${port}`); | |
console.log(__dirname); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment