简体   繁体   English

Flask Azure Web 应用程序部署成功但显示默认页面

[英]Flask Azure web app deployed successfully but showing default page

I deployed a python flask app with azure web service using local git.我使用本地 git 部署了一个带有 azure web 服务的 python flask 应用程序。 The status in the deployment center shows "success" but when i go to the web page, it is still the default page that tells me I'm running python 3.6.6.部署中心的状态显示“成功”,但是当我转到网页时,它仍然是默认页面,告诉我我正在运行 python 3.6.6。

When i navigate to the kudu git clone uri it says " no route registered for '/testapp1.git'当我导航到 kudu git clone uri 时,它说“没有为 '/testapp1.git' 注册的路由

The /wwwroot folder in kudu also has the following files. kudu 中的 /wwwroot 文件夹也有以下文件。

env
static (css folder)
__pycache__
app.py
hostingstart-python.html
hostingstart-python.py
index.html
requirements.txt
web.config

A potential problem could be because the web.config file is still refering to the hostingstart-python.application.一个潜在的问题可能是因为 web.config 文件仍然引用了 hostsstart-python.application。

<configuration>
   <appSettings>
      <add key ="pythonpath" value="%systemDrive%home\site\wwwroot" />
      <add key ="WSGI_HANDLER" value="hostingstart-python.application" />
   </appSettings>
</configuration>

I tried to follow the instructions on https://docs.microsoft.com/en-us/azure/app-service/containers/how-to-configure-python but this is for linux so i'm not sure what to do as i'm running Windows 10.我试图按照https://docs.microsoft.com/en-us/azure/app-service/containers/how-to-configure-python上的说明进行操作,但这是针对 linux 的,所以我不知道该怎么做因为我正在运行 Windows 10。

Please refer to my work steps and see if the error still shows up.:请参考我的工作步骤,看看错误是否仍然出现。:

As you found in the Managing Python on Azure App Service , Azure App Service provide you with a site extension .正如你在 Azure 应用服务上管理 Python 中发现的那样,Azure 应用服务为你提供了一个site extension You could install packages on KUDU console .您可以在KUDU console上安装软件包。

Step 1 : Create azure web app and add Extensions(here is Python 3.6.4 x64)第 1 步:创建 azure web 应用程序并添加扩展(这里是 Python 3.6.4 x64)

在此处输入图片说明

Step 2 : Publish your flask project and add the web.config .第 2 步:发布您的flask项目并添加web.config

web.config:网络配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="WSGI_HANDLER" value="<Your Project Name>.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\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
    </handlers>
  </system.webServer>
</configuration>

Step 3: Switch to the Kudu CMD and commands cd Python361x64 and touch get-pip.py and copy the content of the url https://bootstrap.pypa.io/get-pip.py into the get-pip.py via Edit button, then run python get-pip.py to install the pip tool.第三步:切换到Kudu CMD,命令cd Python361x64touch get-pip.py ,通过Edit将url https://bootstrap.pypa.io/get-pip.py的内容复制到get-pip.py按钮,然后运行python get-pip.py来安装 pip 工具。

在此处输入图片说明

Step 4 : Install any packages you need via eg: python -m pip install Flask第 4 步:通过例如: python -m pip install Flask您需要的任何软件包

在此处输入图片说明

BTW,you could remove the default homepage.顺便说一句,您可以删除默认主页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM