我有一个用 python 编写的基于 api 的 Web 应用程序FastApi https://fastapi.tiangolo.com/它使用Uvicorn https://www.uvicorn.org/ or 超级玉米 https://pgjones.gitlab.io/hypercorn/用于部署。这些都是基于 ASGI 的服务器。有没有办法在此基础上运行 IIS?
你绝对可以通过IIS运行。以下是您可能有的两种选择(我使用 Hypercorn):
-
HTTP平台处理程序
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTPS force" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform requestTimeout="00:05:00" startupTimeLimit="120" startupRetryCount="3" stdoutLogEnabled="true" stdoutLogFile=".\logs\python-stdout" processPath="[PATH TO YOUR PYTHON EXE]" arguments="-m hypercorn app.main:app -b 127.0.0.1:%HTTP_PLATFORM_PORT% --keep-alive 5 --worker-class asyncio --workers 9">
<environmentVariables>
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
-
AspNetCoreModuleV2(如果使用此模块,则必须有一个 config.py 才能正确绑定 URL 和端口。)
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="[PATH TO PYTHON EXE]" arguments="-m hypercorn app.main:app --config file:config.py" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" requestTimeout="00:26:00" /></system.webServer> </location><system.webServer></system.webServer> </configuration>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)