【发布时间】:2019-04-11 21:14:34
【问题描述】:
按照https://docs.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2019 中的步骤将flask 应用程序配置为在IIS 后面运行并在线搜索我找不到解决我问题的解决方案。
我的 web.config 为:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="C:\envs\Scripts\python.exe"
arguments="-m flask run --port %HTTP_PLATFORM_PORT%"
stdoutLogEnabled="true"
stdoutLogFile="C:\logs\python.log"
startupTimeLimit="60"
processesPerApplication="16">
<environmentVariables>
<environmentVariable name="FLASK_APP" value="app.py" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
访问该网站只是吐出以下内容。我尝试了所有可能的解决方案,包括授予 IIS_IUSRS 访问权限。在命令提示符下运行应用程序运行良好。 IIS 错误消息没有帮助。
编辑:
安装 http 平台处理程序后,现在在不同的开发盒上,我可以看到处理程序在工作,但只是一个不同的怪物:502.3 Bad Gateway
详细错误信息:
模块 httpPlatformHandler 请求的网址 http://127.0.0.1:5007/about
通知 ExecuteRequestHandler 物理路径 C:\inetpub\wwwroot\app\about
处理程序 PythonHandler 登录方法匿名
错误代码 0x8007042b 登录用户匿名
这告诉我处理程序只是将 url 作为我的应用程序根目录中的文件夹处理,因为 http://127.0.0.1:5007/about 只不过是一个路径:
myapp_about.py:
from flask import Blueprint, jsonify
myapp_about = Blueprint('about', __name__)
@myapp_about.route('/about')
def get_about():
return jsonify({"wow": "We really are routed to here. maybe not"})
【问题讨论】:
-
你在iis中添加了python和fast cgi的处理程序映射吗?medium.com/@bilalbayasut/…
-
@JalpaPanchal 我使用的是 HttpPlatform 处理程序而不是 FastCGI 处理程序。
-
你可能需要添加requireAccess:
-
@JalpaPanchal 我会试试那个,但我现在在另一个盒子上,并对问题进行了编辑。