I am having some trouble hosting a Flask web service onto Windows Server through IIS. I have followed the tutorial found here:
And have used the resource here to better understand the wfastcgi module: https://pypi.python.org/pypi/wfastcgi
And while I've gotten the tutorial flask app to work as outlined in the tutorial, when I try to host my own Flask app, I get an odd error. I should mention my flask app works perfectly through cmd prompt.
It seems that when the wfastcgi.py module runs, it doesn't recognize the call to a Handler constructor. Here is the error I am getting:
Traceback (most recent call last):
File "C:\web_services\guest_reg_api\wfastcgi.py", line 847, in main
result = handler(record.params, response.start)
TypeError: 'module' object is not callable
In the past, I've had these errors because Windows can't find a Python module, but adding the module's location to my Path system Variables usually solves the issue.
I've verified that all references to Python, Flask, and wfastcgi.py are in my path system variables
I can successfully host an http site through IIS on the same server.
Here is my web.config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Flask" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python27\python.exe|C:\web_services\guest_reg_api\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
<add name="python-wfastcgi" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python27\python.exe|C:\Python27\Lib\site-packages\wfastcgi.pyc" resourceType="File" />
</handlers>
</system.webServer>
<appSettings>
<!-- Required settings -->
<add key="WSGI_HANDLER" value="guestreg_api_v2.app" />
<add key="PYTHONPATH" value="C:\web_services\guest_reg_api" />
</appSettings>
</configuration>
I feel like the issue is one of a few things:
- Python module visibility in Windows due to some error in the way I set System Variables
- An error in my web.config file
- I'm working on Windows server setup by our IT department. I am told that I have administrative privileges, but sometimes I am prohibited from doing certain things... maybe the permissions set on the server are interfering with the IIS web service hosting process?
I'm not sure how to proceed, outside of trying to deploy the service through apache. I'd prefer this method, though, as I feel like I'm very close to fixing this.
Thanks