【问题标题】:Flask app getting 0x8007000d error with IIS使用 IIS 的 Flask 应用程序出现 0x8007000d 错误
【发布时间】: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>
这是我的 app.py:
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>
更新:根据收到的 cmets,添加额外的错误信息 这是我得到的错误(没有安装 httpplatformhandler),发生这种情况时事件日志中没有任何内容: 这是我安装 httpplatformhandler 后得到的错误: 使用 500.3 消息,我还从事件日志中的 HttpPlatformHandler 获得了一堆事件 1000:

【问题讨论】:

  • 下载安装HttpPlatformHandler请iis.net/downloads/microsoft/httpplatformhandler
  • 你能告诉我你的错误页面的细节吗?或者你可以尝试使用failed request tracking查看具体的详细错误信息。
  • 我在谷歌搜索 0x80070057 (github.com/aspnet/Hosting/issues/866) 时发现的一个建议是卸载 httpplatformhandler,因为 .net 核心已经将其烘焙(我有 .net 核心 3.1.6)。因此,我不确定是否要继续安装 httpplatformhandler。
  • 你解决过这个问题吗?我在尝试使简单的烧瓶应用程序与 httpPlatformHandler 一起工作时遇到了同样的问题

标签: flask iis


【解决方案1】:

您似乎没有正确的权限访问 D:\python39\python.exe 和 D:\inetpub\wwwroot\flasktest.py。

  1. 打开 IIS 管理器 -> 选择您添加 HttpPlatformHandler 的站点

  2. 在功能视图中单击 Handler Mappings -> 选择 HttpPlatformHandler

  3. 单击操作面板中的编辑功能权限

  4. 确保您已检查执行权限

【讨论】:

  • 我试过了,但仍然收到 500.3 错误
  • 在您的活动日志中,我发现您发布的图片是一般信息,您能告诉我详细信息吗?
  • 似乎只有“Process '0' 无法启动。端口 = 22700,错误代码 = '-2147024809'。"
  • 确保 IIS_IUSRS 具有 python39 和 wwwroot 访问权限。如果这不能解决问题,请尝试使用失败的请求跟踪。
猜你喜欢
  • 1970-01-01
  • 2017-02-18
  • 2020-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-11
  • 1970-01-01
相关资源
最近更新 更多