wafo.js
v1.0.4
Published
A package for creating a web application from an object
Maintainers
Readme
Wafo Package Documentation
Wafo.js is package for creating a web application from an object
Installation
To install the Wafo package, run the following command:
npm i wafo.jsUsage
First, require the Wafo class in your JavaScript file:
const Wafo = require("wafo.js");Creating an Instance
To create an instance of the Wafo class, use the following code:
const wafo = new Wafo();Defining Routes
To define a route, use the route() method. It takes two parameters: route and json. The route parameter specifies the URL path, and the json parameter contains the structure of the HTML page.
Example usage:
wafo.route("/", {
head: {
title: {
content: "My Page"
}
},
body: {
h1: {
attributes: { class: "title" },
content: "Welcome to my page!"
}
}
});Starting the Server
To start the server and listen for incoming requests, use the listen() method. It takes two parameters: host and port.
Example usage:
wafo.listen("localhost", 3000);Example
Here's a complete example of using the Wafo package to create a simple HTML page:
const Wafo = require("wafo.js");
const wafo = new Wafo();
wafo.route("/", {
head: {
title: {
content: "My Page"
}
},
body: {
h1: {
attributes: { class: "title" },
content: "Welcome to my page!"
}
}
});
wafo.listen("localhost", 3000);That's it! You've successfully created a basic HTML page using the Wafo package.
