Azure API上的托管烧瓶(python)API
团队,我一直在尝试在Azure API应用程序上托管flask API。它不起作用了 Azure API应用程序正在运行。托管页面将以python版本3.6.6打开 我无法主持简单的hello world项目,我收到的不同错误如下Azure API上的托管烧瓶(python)API,python,python-3.x,azure,flask,azure-api-apps,Python,Python 3.x,Azure,Flask,Azure Api Apps,团队,我一直在尝试在Azure API应用程序上托管flask API。它不起作用了 Azure API应用程序正在运行。托管页面将以python版本3.6.6打开 我无法主持简单的hello world项目,我收到的不同错误如下 无法在web.config中添加处理程序。如果添加500个错误 无法从kudu安装烧瓶。获取权限错误。使用--user安装时,flask将安装到用户文件夹中。已更改包含此文件夹的路径,但仍无法导入flask 使用git部署。上载成功,但在部署时出错,说明运行时版本的p
- 遵循azure帮助部分中给出的说明
- 还添加了Python3.6扩展。没有什么变化
- 类似的SO线程可以帮助您使用
WSGI\u Handle
部署flask应用程序
或者,如果您只想知道如何在Azure上的Official flask网站上运行hello world
演示,就像在本地计算机上使用flask run
一样,您可以按照下面的步骤操作
pip
并在Kudu控制台中安装flask
D:\home\python364x64>python -V
Python 3.6.4
D:\home\python364x64>pip -V
pip 9.0.1 from D:\home\python364x64\lib\site-packages (python 3.6)
D:\home\python364x64>python -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-18.1
D:\home\python364x64>pip install flask
Collecting flask
Downloading https://files.pythonhosted.org/packages/7f/e7/08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4b/Flask-1.0.2-py2.py3-none-any.whl (91kB)
Collecting click>=5.1 (from flask)
Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
Collecting Jinja2>=2.10 (from flask)
Downloading https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB)
Collecting Werkzeug>=0.14 (from flask)
Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
Collecting itsdangerous>=0.24 (from flask)
Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10->flask)
Downloading https://files.pythonhosted.org/packages/9d/80/9a5daf3ed7b8482e72ee138cef602b538cfba5c507e24e39fb95c189b16b/MarkupSafe-1.1.0-cp36-cp36m-win_amd64.whl
Installing collected packages: click, MarkupSafe, Jinja2, Werkzeug, itsdangerous, flask
The script flask.exe is installed in 'D:\home\python364x64\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed Jinja2-2.10 MarkupSafe-1.1.0 Werkzeug-0.14.1 click-7.0 flask-1.0.2 itsdangerous-1.1.0
app.py
和web.config
文件,
app.py
内容:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
<add key="PATH" value="D:\home\python364x64;D:\home\python364x64\Scripts;%PATH%" />
</appSettings>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="D:\home\python364x64\Scripts\flask.exe" arguments="run --port %HTTP_PLATFORM_PORT%" stdoutLogEnabled="true" startupRetryCount='10'>
</httpPlatform>
</system.webServer>
</configuration>
web.config
内容:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
<add key="PATH" value="D:\home\python364x64;D:\home\python364x64\Scripts;%PATH%" />
</appSettings>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="D:\home\python364x64\Scripts\flask.exe" arguments="run --port %HTTP_PLATFORM_PORT%" stdoutLogEnabled="true" startupRetryCount='10'>
</httpPlatform>
</system.webServer>
</configuration>
谢谢您的回复。当尝试使用此答案中给出的详细信息时,CGI错误返回如下。“指定的CGI应用程序遇到错误,服务器终止了该进程。”我正在查看其他答案以尝试使用它们。