Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...