question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

wfastcgi 2.2 + IIS 8 + Flask 0.10.1 + Python 3.5.1 = error

See original GitHub issue

I am running a flask webapp of which standalone script runs fine. When it is integrated into IIS 8 with wfastcgi we get this error:

Error occurred while reading WSGI handler:

Traceback (most recent call last):
  File "c:\python\python34\lib\site-packages\wfastcgi.py", line 779, in main
    env, handler = read_wsgi_handler(response.physical_path)
  File "c:\python\python34\lib\site-packages\wfastcgi.py", line 621, in read_wsgi_handler
    handler = get_wsgi_handler(os.getenv('WSGI_HANDLER'))
  File "c:\python\python34\lib\site-packages\wfastcgi.py", line 594, in get_wsgi_handler
    handler = handler()
TypeError: __call__() missing 2 required positional arguments: 'environ' and 'start_response'


StdOut: 

StdErr: 

web.config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appSettings>
    <add key="WSGI_HANDLER" value="app.app()" />
    <add key="PYTHONPATH" value="C:\Flaskapp" />
  </appSettings>
  <system.webServer>
    <!--<handlers accessPolicy="Read, Execute, Script" />-->
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
            <add name="Python FastCGI" 
            path="*" verb="*" 
            modules="FastCgiModule" 
            scriptProcessor="C:\python\python34\python.exe|c:\python\python34\lib\site-packages\wfastcgi.py" 
            resourceType="Unspecified" requireAccess="Script" />
    </handlers>
  </system.webServer>
</configuration>

How can this be fixed? Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chuckmo8commented, Apr 27, 2016

The major document I read was wfastcgi on pypi: https://pypi.python.org/pypi/wfastcgi

I also googled with these key words “python flask iis”

https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-classic-python-django-web-app/

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

https://heejune.me/2015/04/22/running-python-flask-on-a-local-iis-not-azure-with-wfastcgi-py/

Most of the examples I have gone through were with blankets in WSGI_HANDLER value. We followed that and failed.

1reaction
zoobacommented, Apr 27, 2016

At a guess, your WSGI_HANDLER app setting should be app.app (without the trailing ()). That way, wfastcgi will do:

handler = __import__("app")
handler = getattr(handler, "app")
handler(environ, start_response)

Currently, it’s doing this:

handler = __import__("app")
handler = getattr(handler, "app")
handler = handler()  # Call here is missing arguments
#handler(environ, start_response)  never reached
Read more comments on GitHub >

github_iconTop Results From Across the Web

wfastcgi 2.2 + IIS 8 + Flask 0.10.1 + Python 3.5.1 = error
I am running a flask webapp of which standalone script runs fine. When it is integrated into IIS 8 with wfastcgi we get...
Read more >
Getting 500 Internal Server Error when setting up Python ...
I have below configuration settings on IIS 7.5 and running Python Flask with FastCgiModule. Here are the steps you can take:.
Read more >
Getting 500 Internal Server Error when setting up Python and ...
Made sure the CGI windows feature was installed. In the IIS Manager, highlighted web server and in FastCGI Settings added an application with...
Read more >
How to setup Flask web app on IIS in windows using Python ...
I've been struggling to get python 3.11 + flask app running within iis using wfastCGI. I havent found anythig about wfastcgi and 3.11...
Read more >
wfastcgi
wfastcgi.py provides a bridge between IIS and Python using WSGI and FastCGI, similar to what mod_python provides for Apache HTTP Server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found