0

So I have created a local web server that uses jQuery. I also have a Twitch IRC bot which utilizes node.js along with the TMI and TwitchAPI library.

Goal I want to use the local web server to manage the IRC bot. For instance, the local server would have START_Button which would run a Connect method within the IRC Bot.

Problem: How would I execute a node.js script using a simple HTML input button. When I call the Connect method, I get a require(...) is not defined and found out why with a little research .

Any ideas?

Jose Paredes
  • 3,882
  • 3
  • 26
  • 50
John
  • 1
  • 1

1 Answers1

3

If you want to run Node.js script on button press, you should:

  1. Start the local web server
  2. Make it serve HTML page, that has the button
  3. On button press send HTTP request to the server
  4. The request hander can then run any Node.js code you want
Dennis Yarmosh
  • 204
  • 2
  • 3
  • 1
    Quick way to do this is to `npm install -g http-server`, cd into project folder and type `http-server` – Win Aug 22 '17 at 19:49
  • Would npm install -g watch-http-server . Using watch-http-server instead of http-server because it constantly update. – John Aug 22 '17 at 19:53