First you need to create a Folder. That folder opens in the vs code and installs some packages. Some commands are available below.
*Commands *
1) npm init
2) npm install nodemon
Create file index.js
After that looks like this:
index.js
var htttp = require("http");
var fs = require("fs");
var port = 1010;
var val = htttp.createServer(function (req, res) {
fs.writeFile("testing.html", "This is 2021 ", function (err) {
if (err) throw err;
res.write("Your file Created..!");
res.end();
});
});
val.listen(port, () => {
console.log("Server Started on ", port);
});
Then Start the server, Go to the command prompt and Type Command.
npx nodemon index.js
Your server will start, and your testing.html
created in the folder looks like this.
testing.html
Top comments (0)