Search code examples
flaskpython-3.5iis-10

I am facing issues while hosting my Flask web application in IIS


I am using Python3.5, IIS10 to deploy flask web application in iis. Can anyone help me to set up iis with python. I saw many examples but i could not able to do so. I guess the error must be related to web.config

My error is

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>

Solution

  • Add applicationHost.xdt under Your Project directory..

    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>
    

    Refresh and Restart your Site.Now it will work..