I have c++ code that can be compiled under Linux, windows or Mac OS. The code compares two images. I would like to have its front end running on a browser and make available to the www. 
I am familiar with hosting and dns and that is not the issue. what I can't seem to figure out is:

How do I invoke the script once the image is uploaded by users? 
The results from the code needs to be displayed back to the browser. How can a callback be set up for this?

Is there a php solution? Or python (with flask)?
You can use sockets, and start listening on some port from C++ program, then from PHP you can connect and send/receive data to/from your program.
Web front-end for c++ code