-1

I am wondering how to make a website that controls some of the c++ code such as calling a method when clicking on a button. I googled my ass off however all I could find was for python.

axy_david
  • 53
  • 2
  • 6
  • Welcome to the big world of CLOUD from small world embedded. – Manthan Tilva May 17 '16 at 15:56
  • Have the button link to a PHP page and execute the code. [Here's how](http://stackoverflow.com/questions/4279003/execute-c-program-with-php-script) – Jon May 17 '16 at 15:58
  • You'll need a webserver running on your pi. There are some tailored for small systems like [lighthttpd](https://www.lighttpd.net/). C++ code can be linked through CGI interface. – πάντα ῥεῖ May 17 '16 at 16:02

2 Answers2

0

You can send http request to your c++ backend when clicking on a button. You can use Boost.asio to write you c++ server. Or you can you can write your server with python or other language framework, and call c++ function in those language.

Shangtong Zhang
  • 1,579
  • 1
  • 11
  • 18
0

My recomendation is to use a proper web-server that handles most of the page views, including static pages. Then for some specific URL it proxies requests locally to your program which listens for such "API calls" on a specific port.

So for your button, you can have the event handler do an AJAX call to e.g. http://your-host.example.com/special/path/do_something?some_argument=foo&some_other_argument=123.

The local web-server then proxies request to /special/path/ to your program.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621