LiteNode's logo

LiteNode

Docs GitHub logo
▶ Usage

Documentation

Sending HTML

The html method is an essential addition to the response object, streamlining the process of sending HTML responses. By setting the Content-Type header to text/html and delivering the provided HTML content as the response body, this method ensures that HTML content is correctly handled and returned to the client. This feature is particularly useful for API endpoints or responses where HTML content is required.

html

Description:

The html method sets the Content-Type header to text/html and sends the provided HTML content as the response body. This method simplifies the process of returning HTML responses to the client.

Signature:

html(html: string, statusCode?: number): void

Parameters:

Example:

// Route to handle sending HTML response
app.get("/html-page", (req, res) => {
    res.html("<h1>Welcome to the HTML page</h1>")
})

In this example, the /html-page route will send the HTML response <h1>Welcome to the HTML page</h1> to the client.

Content