在IIS中托管Flask Web应用程序时遇到问题

时间:2018-09-05 10:59:18

标签: flask python-3.5 iis-10

我正在使用IIS10的Python3.5,IIS10在iis中部署flask Web应用程序。谁能帮我用python设置iis。我看到了很多例子,但我做不到。我猜该错误必须与web.config

有关

我的错误是

HTTP Error 500.0 - Internal Server Error C:\Program Files\Python35\python.exe - The FastCGI process exceeded configured request timeout

web.config

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appSettings>
        <add key="WSGI_HANDLER" value="Bot_Chat.app" />
        <add key="PYTHONPATH" value="C:/inetpub/wwwroot/EtownChatBot/;C:\Program Files\Python35;C:\Program Files\Python35\Lib;C:\Program Files\Python35\Lib\site-packages;C:\Program Files\Python35\DLLs;" />
    </appSettings>
    <system.webServer>
        <handlers>
            <remove name="CGI-exe" />
            <add name="FlaskHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files\Python35\python.exe|&quot;C:\inetpub\wwwroot\EtownChatBot\wfastcgi.py&quot;" resourceType="Unspecified" />
        </handlers>
        <directoryBrowse enabled="true" />
        <security>
            <requestFiltering>
                <fileExtensions>
                    <add fileExtension=".py" allowed="true" />
                    <add fileExtension=".html" allowed="true" />
                </fileExtensions>

            </requestFiltering>
        </security>

    </system.webServer>
</configuration>

1 个答案:

答案 0 :(得分:2)

在您的项目目录下添加applicationHost.xdt。

applicationHost.xdt

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.webServer>
    <fastCgi>
      <application xdt:Locator="Match(fullPath)" xdt:Transform="SetAttributes(activityTimeout)"
            fullPath="C:\Program Files\Python35\python.exe" activityTimeout="600"/>
    </fastCgi>
  </system.webServer>
</configuration>

刷新并重新启动您的站点。现在它将正常工作。