Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

javascript - How can I Execute NodeJS Server Client Side With Html Button Or Alternative If Not Possible?

Intro: Hello. So I started on a chat based social media app with Socket.io, but it seems like the client needs to open a localhost server to be able to communicate with the socket manager on my web API (node, express, socket.io).

Question Tree: Is it possible to make a nodejs server client side and execute a script with an html front end button so that the socket has a localhost to run tcp on to communicate to my web API? If so, how can I do this? If not, what are some alternatives to achieve the same results?

conclusion: Any help is appreciated, I am learning how to do this sort of development for school and I just want some clarity. Thank you!

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is possible if you are on linux you have to make a bash script file that will run your app.js or index.js node file, for ex

node app.js

that will get executed when you press a button on page which again is easy if you use some server side language like php if you are interested here is the link for moreenter link description here

with just html its not possible easily its just too much of a task, just type that command in your terminal and you are good to go

rather you can make a script like bash in linux or bat in windows, that will open the server client side if you open that script file.

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share