Web应用已成功部署

Web应用已成功部署

本文介绍了Flask Azure Web应用已成功部署,但显示默认页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用本地git在azure Web服务中部署了python flask应用程序.部署中心的状态显示为成功",但是当我转到网页时,它仍然是默认页面,告诉我我正在运行python 3.6.6.

当我导航到kudu git clone uri时,它说没有为'/testapp1.git'注册的路由

kudu中的/wwwroot文件夹还具有以下文件.

  env静态(css文件夹)__pycache__app.pyHostingstart-python.htmlhostingstart-python.pyindex.htmlrequirements.txtweb.config 

潜在的问题可能是因为web.config文件仍然引用了hostingstart-python.application.

 < configuration>< appSettings><添加密钥="pythonpath" value =%systemDrive%home \ site \ wwwroot"/><添加密钥="WSGI_HANDLER" value ="hostingstart-python.application"/></appSettings></configuration> 

我尝试遵循

第2步:发布您的 flask 项目并添加 web.config .

web.config:

 <?xml version ="1.0" encoding ="utf-8"?><配置>< appSettings><添加key ="WSGI_HANDLER" value =<您的项目名称> .app"/><添加key ="PYTHONPATH" value ="D:\ home \ site \ wwwroot"/><添加key ="WSGI_LOG" value ="D:\ home \ LogFiles \ wfastcgi.log"/></appSettings>< system.webServer><处理程序><添加名称="PythonHandler" path ="*"动词="*" modules ="FastCgiModule" scriptProcessor ="D:\ home \ Python364x64 \ python.exe | D:\ home \ Python364x64 \ wfastcgi.py" resourceType =未指定" requireAccess ="Script"/></handlers></system.webServer></configuration> 

第3步:切换到Kudu CMD并命令 cd Python361x64 touch get-pip.py 并复制URL的内容 https://通过编辑"按钮将bootstrap.pypa.io/get-pip.py 放入 get-pip.py ,然后运行 python get-pip.py 进行安装点子工具.

第4步:通过以下方式安装所需的任何软件包: python -m pip install Flask

顺便说一句,您可以删除默认主页.

I deployed a python flask app with azure web service using local git. 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.

When i navigate to the kudu git clone uri it says " no route registered for '/testapp1.git'

The /wwwroot folder in kudu also has the following files.

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.

<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.

解决方案

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. You could install packages on KUDU console.

Step 1 : Create azure web app and add Extensions(here is Python 3.6.4 x64)

Step 2 : Publish your flask project and add the 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.

Step 4 : Install any packages you need via e.g: python -m pip install Flask

BTW,you could remove the default homepage.

这篇关于Flask Azure Web应用已成功部署,但显示默认页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 09:56