问题
I have followed all the steps as per the azure website. I can see the python 3.6 version running on Azure. I have installed the python 3.6 extension and added a proper web.config file. When I try to open my URL I am getting the below error
http://myuniqueappname114.azurewebsites.net/
Any idea how to fix this error pls
回答1:
Generally, the issue was caused by your web.config file configured incorrectly to not start up your flask app from IIS.
Here is my case for deploying flask Hello World app on Azure Website, which you can refer to to check your deployment whether be correct.
- I installed a Python extension
python364x86underD:\home. Maybe yours installed ispython364x64. - I commanded
pip install flaskin the pathD:\home\python364x86via Kudo console. - My file structure under
wwwrootas the figure below via commandtree /F /A. The
__init__.pyfile content is like the Flask officalHellodemo.from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run()My
web.configfile content is as below, notepython364x86I used in the propertyscriptProcessorof tagsystem.webServer > handles > addat here.<?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="PYTHONPATH" value="D:\home\site\wwwroot" /> <add key="WSGI_HANDLER" value="myflask.app" /> </appSettings> <system.webServer> <handlers> <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python364x86\python.exe|D:\home\python364x86\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> </handlers> </system.webServer> </configuration>
Then the demo app works.
If your case is different from mine, please post your web.config file content and other necessary info to help fixing up your issue.
来源:https://stackoverflow.com/questions/54121080/hosting-flaskpython-app-throws-cgi-error