如何在 IIS 服务器上部署 FastAPI Web 应用程序?

Sha*_*rak 6 windows iis web-deployment server fastapi

我有一个 FastAPI Web 应用程序,正在尝试将其部署在 Windows Server 2019 上的 IIS 版本 10.0.* 上。

现在,我可以在本地运行该应用程序,没有任何问题,您可以在这里找到存储库: https: //github.com/shaybarak11/Twitter-API

为了在本地运行它,我正在做的是通过 CMD 运行应用程序:
python main.py

在 main.py 文件中,我有这行启动应用程序的代码:

uvicorn.run("main:app", host="0.0.0.0", port=8000, log_level="info")

现在,我尝试在 IIS 上部署这个应用程序。这些是我到目前为止所采取的步骤:

  1. 在Windows服务器上下载IIS。
  2. 在 IIS 管理器页面上点击添加网站。
  3. 添加了项目目录的物理路径。
  4. 以管理员身份连接。
  5. 转到处理程序映射并添加 python 解释器。
  6. 按照为 python 应用程序配置 web.config 文件的指南,我现在收到 HTTP 错误 500.19 - 这表明问题出在我的 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="C:\Users\Administrator\AppData\Local\Programs\Python\Python39\python.exe"
                  arguments="C:\Users\Administrator\Desktop\Twitter-API\main.py"
                  stdoutLogEnabled="true"
          stdoutLogFile="c:\home\LogFiles\python.log"
                  startupTimeLimit="60"
                  processesPerApplication="16">
      <environmentVariables>
        <environmentVariable name="USERNAME" value="root" />
    <environmentVariable name="PASSWORD" value="password" />
      </environmentVariables>
    </httpPlatform>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

有人知道错误是什么吗?

非常感谢,
谢伊。