将烧瓶应用程序部署到Windows Azure并接收WfastCGI错误



我一直在尝试将网站部署到App Services的Azure。我已经使用了一个要求。txt文件安装烧瓶和wfastcgi,以及其他所需的依赖项也使用了python 3.6。我已经设置了Web.config文件,以正确启动Python并使用Wfastcgi软件包。当我尝试导航到网站时,我会遇到这样的Wfastcgi错误。

Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:Python34Scriptswfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:Python34Scriptswfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:Python34Scriptswfastcgi.py", line 551, in get_wsgi_handler
raise ValueError('"%s" could not be imported' % handler_name)
ValueError: "D:homesitewwwrootFlaskTest.app" could not be imported

我的文件存储在" D: home site wwwroot"中它的结构像

D:homesitewwwroot |FlaskTest.py |web.config |requirements.txt

我的flasktest.py只是简单的QuickStart烧瓶应用程序。

from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
 return "Hello from FastCGI via IIS!"
if __name__ == '__main__':
    app.run()

这是我的web.config:

<configuration>
<system.webServer>
<handlers>
   <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule"
    scriptProcessor="D:Python34python.exe|D:Python34scriptswfastcgi.py"
    resourceType="Unspecified" requireAccess="Script"/>
</handlers>
<httpErrors errorMode="Detailed" />
</system.webServer>
<appSettings>
 <add key="PYTHONPATH" value="D:homesitewwwroot" />
 <add key="WSGI_HANDLER" value="D:homesitewwwrootFlaskTest.app" />
 <add key="WSGI_LOG" value="D:homeLogFileswfastcgi.log"/>
</appSettings>
</configuration>

我真的不确定WSGI_HANDLER键有什么问题。从我阅读的所有内容中,这都可以起作用。我尝试在目录中添加 init .py,但我仍然会收到错误。由于某种原因,我可以理解Wfastcgi在导入"应用程序"对象时遇到困难,因为那是我所命名为"烧瓶对象"。当我一直在猛烈抨击它几天时,任何可以丢掉的光线都将不胜感激。

从评论中复制。

Microsoft在Windows上的Azure App Service上弃用Python(以及诸如Wfastcgi之类的基础组件),

https://learn.microsoft.com/en-us/visualstudio/python/publishing-python-web-applications-to-azure-from-visual-visual-studio?view=vs-2017

因此,今天托管Python应用程序的唯一可行方法是在Linux上使用App Service。

我知道这是超级旧的,但是我实际上可以在django应用程序上使用cr脚的工作来完成此工作。如果您从字面上进入WFASTCGI文件,则可以在此处添加环境变量,并且您的应用程序将起作用。不确定这有多糟糕(从明显的维护问题出来),但是它在Windows Server 2016,IIS 10和Python 3.7中对我来说很好。

好 - 对此的更新...如果您在IIS上使用FastCGI模块。您可以在该特定scriptprocessor的设置上添加环境变量,并且可以毫无问题地拉动它们。

最新更新