'Making web server run scripts

I'm sure a 100 people asked this before but I couldn't find the right key words to google it.

Simply put: How do I make a web client send information to the web server the right way?

I have a simple website set up with apache 2 on a raspberry with ubuntu. Something very basic. I'd like to have a button on my website that makes my server run a script (I wrote that script in c++ but I don't care if I have to translate it). One solution is using JS client-side to send a message to my server on a specific port (say 50000), and having the server listen on that port with a custom listener.

That works fine, but I'm sure there is a right way to do this. How should I do this so that people won't be pissed by my architecture too much? (+using other ports than 80 and 443 on browser may not work if the client blocks other ports)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source