Run node.js app from html by pressing a button

714 Views Asked by At

I made a telegram bot in node js and I would like to be able to start it by pressing a button from an html page, how can I do it? also I would like that even after the web page is closed, the bot continues to work.

To run the bot from the console I use the command: node bot.js

1

There are 1 best solutions below

3
On BEST ANSWER

The best way will be: Creating a server in nodejs and post the request from the html button.

STEP 1: Create html from for sending request to server: Can a html button perform a POST request?

STEP 2: Create the server for receiving the request and do the work: How is an HTTP POST request made in node.js?