I want to render some HTML text within my express route. I know one of the options is using the npm-needle module but I was unsure if we there is any way to use npm-express and npm-http within the same route defined.
What I want is something like:
var http = require("http");
var express = require("express");
var app = express();
app.get("/", function (req, res) {
var params = req.params;
var url = req.query["url"];
let handleRequest = (request, response) => {
response.writeHead(200, {
"Content-Type": "text/plain",
});
response.write("Hi There! " + url);
response.end();
};
});
app.listen(5000);
//http.createServer(handleRequest).listen(8000); ---> not using this in the code
Is something of this type possible? Thanks!
{{url}}
\`) – Abhinav Sharma Jun 20 '20 at 20:34' + url + '
');`. The `{{url}}` syntax involves using a template engine to render your page which is something else entirely. You can't just grab little pieces of code from random questions and insert them in your project. You need to understand how things actually work. – jfriend00 Jun 20 '20 at 20:35