【发布时间】:2020-11-24 17:16:02
【问题描述】:
我正在尝试让一个非常基本的烧瓶应用程序在 Windows Server 2019 上运行的 IIS 10 上运行。 我遵循了来自:https://docs.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2019
的 HTTPPlatform Handler 指令但我不断收到 HTTP 500.19 错误,错误代码为 0x8007000d。通过谷歌搜索,我怀疑问题出在我的 web.config 中,但我不知道出了什么问题。该应用程序在命令行中运行良好。 这是我的 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="D:\python39\python.exe"
arguments="D:\inetpub\wwwroot\flasktest.py"
stdoutLogEnabled="true"
stdoutLogFile="d:\logs\python.log"
startupTimeLimit="60"
processesPerApplication="16">
<environmentVariables>
<environmentVariable name="SERVER_PORT" value="9010" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
from flask import Flask, render_template
app = Flask(__name__)
#app.debug = True
@app.route("/", methods=('GET', 'POST'))
def home():
return render_template('main.html', hello = 'hello world')
if __name__ == '__main__':
app.run(host='0.0.0.0',port=9010)
这是我的 main.html
{% extends 'layout.html' %}
{% block content %}
<div class="container">
<div class="leftrow1">
{{ hello }}
</div>
<div class="leftrow2">
</div>
<div class="leftrow3">
</div>
<div class="leftrow4">
</div>
<div class="main_frame_1">
</div>
<div class="main_frame_2">
</div>
</div>
{% endblock content %}
这是 layout.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
</head>
<body>
{% block content %}
{% endblock content %}
</body>
【问题讨论】:
-
下载安装HttpPlatformHandler请iis.net/downloads/microsoft/httpplatformhandler
-
你能告诉我你的错误页面的细节吗?或者你可以尝试使用failed request tracking查看具体的详细错误信息。
-
我在谷歌搜索 0x80070057 (github.com/aspnet/Hosting/issues/866) 时发现的一个建议是卸载 httpplatformhandler,因为 .net 核心已经将其烘焙(我有 .net 核心 3.1.6)。因此,我不确定是否要继续安装 httpplatformhandler。
-
你解决过这个问题吗?我在尝试使简单的烧瓶应用程序与 httpPlatformHandler 一起工作时遇到了同样的问题