Render raw html in response with Express
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('<h1>Hello, this is a raw HTML response</h1>');
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
In this example, we're using Express to create a simple server. We use the express
module to create an instance of the Express application. Then, we define a route for the root URL using app.get()
. When a GET request is made to the root URL, the server responds with raw HTML using the res.send()
method. Finally, we start the server and listen on port 3000 using app.listen()
.