使用FastCGI在IIS中部署Python Web应用程序(Flask)会收到500 Internal Server Error

时间:2018-10-11 03:13:45

标签: python iis flask fastcgi

我正在尝试在IIS中部署Flask应用。

但是我收到500 FastCGI错误。

错误代码:“ 0x8007010b”

这是我已采取的步骤:

OS:windows10

Python版本:3.6.5

1.install url rewrite2.0

2.pip安装wfastcgi

3。启用wfastcgi

4。创建HelloAPI.py

5.create web.config

HelloAPI.py

from flask import Flask
app=Flask(__name__)

@app.route('/',methods=['GET'])
def index():
    return "Hello Flask!"

if __name__=='__main__':
    app.run(debug=True)

web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="FlaskFastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="d:\users\hhhung1\appdata\local\programs\python\python36-32\python.exe|d:\users\hhhung1\appdata\local\programs\python\python36-32\lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
    <security> 
        <requestFiltering allowDoubleEscaping="true"></requestFiltering> 
    </security> 
  </system.webServer>

  <appSettings>
    <!-- Required settings -->
    <add key="WSGI_HANDLER" value="HelloAPI.app" />
    <add key="PYTHONPATH" value="~/" />
  </appSettings>
</configuration>

有什么想念的吗?

2 个答案:

答案 0 :(得分:1)

问题解决了。我授予r / w权限到python.exe文件夹,它现在可以正常工作。

答案 1 :(得分:0)

您需要对包含“IIS AppPool\DefaultAppPool”的python.exe的整个python文件夹具有读取和执行权限