Allora credo ti serva un webserver che supporti sia php che python. Poi credo ti basti chiamare da ajax lo script .py

Comunque dai un occhiata qui

https://docs.python.org/3.6/howto/webservers.html