Redirecting to PHP file in Flask Redirecting to PHP file in Flask flask flask

Redirecting to PHP file in Flask


Maybe you should run php server (such as Apache or another) on other port (such as 8080) and when you call any php file, make request from your flask server to php server. And result getting from php server show with flask server. I hope, you can find the way how to send request from flask to other server.


render_template() isn't support PHP.

You can use subprocess to run PHP script:

import subprocess as sp@app.route('/example.php')def phpexample():    out = sp.run(["php", "example.php"], stdout=sp.PIPE)    return out.stdout


Flask is not compatible with php. So it can't read php code.