使用 Kudu 在 Azure 上部署 Flask - 仅显示默认页面
Deploy Flask on Azure using Kudu - shows only default page
我在 Python 中构建并部署了 Flask 应用程序到 Azure。我在本地测试了该应用程序,一切正常。我正在使用 Kudu 在 Windows 和 Python 3.6.
上进行部署
但是,应用部署成功后,我只能看到默认页面:
This website is running Python 3.6.6
据我所见,故障出在 Kudu web.config
文件上,该文件如下所示:
<configuration>
<appSettings>
<add key="pythonpath" value="%SystemDrive%\home\site\wwwroot" />
<add key="WSGI_HANDLER" value="hostingstart-python.application" />
</appSettings>
</configuration>
出于某种原因,它指向确实显示默认页面的 hostingstart-python.application
(有 .html
和 .py
文件)。
我的 /wwwroot
文件夹如下所示:
env
templates
.gitignore
app.py
config.py
file_manager.py
hostingstart-python.html
hostingstart-python.py
README.md
requirements.txt
web.config
我尝试了 web.config
文件的各种版本,例如下面的那个,但没有成功。
对于 WSGI_HANDLER
,我输入了网络应用程序的名称,但也许必须有另一个名称?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="UploadToolApp.app"/>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python364x64\python.exe|D:\home\Python364x64/scripts\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
</configuration>
这导致:
The page cannot be displayed because an internal server error has occurred.
解决方案是切换到 Linux 机器,然后一切正常。
我在 Python 中构建并部署了 Flask 应用程序到 Azure。我在本地测试了该应用程序,一切正常。我正在使用 Kudu 在 Windows 和 Python 3.6.
上进行部署但是,应用部署成功后,我只能看到默认页面:
This website is running Python 3.6.6
据我所见,故障出在 Kudu web.config
文件上,该文件如下所示:
<configuration>
<appSettings>
<add key="pythonpath" value="%SystemDrive%\home\site\wwwroot" />
<add key="WSGI_HANDLER" value="hostingstart-python.application" />
</appSettings>
</configuration>
出于某种原因,它指向确实显示默认页面的 hostingstart-python.application
(有 .html
和 .py
文件)。
我的 /wwwroot
文件夹如下所示:
env
templates
.gitignore
app.py
config.py
file_manager.py
hostingstart-python.html
hostingstart-python.py
README.md
requirements.txt
web.config
我尝试了 web.config
文件的各种版本,例如下面的那个,但没有成功。
对于 WSGI_HANDLER
,我输入了网络应用程序的名称,但也许必须有另一个名称?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="UploadToolApp.app"/>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python364x64\python.exe|D:\home\Python364x64/scripts\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
</configuration>
这导致:
The page cannot be displayed because an internal server error has occurred.
解决方案是切换到 Linux 机器,然后一切正常。