我正在尝试在运行python 2.7的Windows 2016服务器VM上使用IIS配置flask。我已按照以下说明进行操作:
http://netdot.co/2015/03/09/flask-on-iis/
当我尝试加载我的网站时,这是我得到的错误:
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:
我进行了一些搜索,发现这篇帖子Flask, wfastcgi, and IIS on Windows Server 2012中的海报似乎也出现了相同的错误。这里没有提供答案,但是我还建立了一个类似于该人创建的web.config文件:
<?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>
我还授予了网站文件夹上的IIS和IUSR的访问权限。我想念什么?