htmlservercreator
v3.0.0
Published
Create a server with HTML Files
Downloads
10
Readme
HTMLServerCreator Rewrite
About
HTMLServerCreator is a node.js package that helps you creating a webpage with html files.
Examples
Creating a simple server.
const creator = require("htmlservercreator")
var app = require("express")()
var server = new creator.server(app, {port: 3000, emitrequestwhen404: false}) // Creating a server in port 3000
server.html("/", require("path").join(__dirname + "/index.html")) // localhost:300
server.html("/yeet", require("path").join(__dirname + "/yeet.html")) // locahost:3000/yeet
server.notfound(require("path").join(__dirname + "/404.html")) // 404
server.on("request", (route, req, res) => {
console.log("Request to " + route)
})
server.listen().then((port) => { // Listen in the port that has been defined in server options
console.log("Listening in port " + port)
})
Methods (<> = required, [] = optional)
creator.server(<expressApp (expressApp)>, [options (Object)]) Creates a HTMLServerCreatorServer server.html(<route (String)>, <path to html file (String)>) Serve a html file to server server.notfound(<path to html file (String)>) Define a html file to use when 404'd server.listen([use default port? (Boolean)], [if not to use default port, port (Number)]) Make the server listen to a port
Test
$ npm test