1

I am trying to configure flask with IIS on a windows 2016 server VM, running python 2.7. I have followed these instructions:

http://netdot.co/2015/03/09/flask-on-iis/

When I try to load my site, this is the error I get:

Error occurred while reading WSGI handler: Traceback (most recent call last): File "C:\inetpub\wwwroot\flask\wfastcgi.py", line 792, in main env, handler = read_wsgi_handler(response.physical_path) File "C:\inetpub\wwwroot\flask\wfastcgi.py", line 634, in read_wsgi_handler handler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) File "C:\inetpub\wwwroot\flask\wfastcgi.py", line 586, in get_wsgi_handler raise Exception('WSGI_HANDLER env var must be set') Exception: WSGI_HANDLER env var must be set StdOut: StdErr: 

I did some searching and found this post Flask, wfastcgi, and IIS on Windows Server 2012 where poster appeared to be getting the same error. No answered was provided here but I also set up a web.config file similar to what that person created:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appSettings>
        <add key="WSGI_HANDLER" value="app.app" />
        <add key="PYTHONPATH" value="c:/inetpub/wwwroot/flask/" />
        <add key="WSGI_LOG" value="C:/TMP/logs/app.log" />
    </appSettings>
    <system.webServer>
        <handlers>
            <add name="python-wfastcgi" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\inetpub\wwwroot\flask\venv\Scripts\python.exe|C:\inetpub\wwwroot\flask\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
    </system.webServer>
</configuration>

I have also granted access on the website folder to IIS and IUSR. What am I missing?

kflaw
  • 424
  • 1
  • 10
  • 26
  • Since the very beginning Microsoft recommends HttpPlatformHandler over FastCGI, https://halfblood.pro/running-flask-web-apps-on-iis-with-httpplatformhandler/ – Lex Li Jul 11 '22 at 06:46

0 Answers0