本文介绍了找不到Azure烧瓶路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio创建一个空白的Flask应用程序。当我在本地运行应用程序时,我得到了预期的 hello world。当我发布到Azure App Service时,会得到一个我没有制作的漂亮的丑陋蓝色主页。该代码在我的项目中不存在,至少在Visual Studio解决方案资源管理器中可以看到。如果我尝试使用<我的帐户名> .azurewebsites.net / test ,我会收到 404 错误。有什么建议吗?

I am using visual studio to create a blank Flask app. When I run the application locally, I get the expected "hello world". When I publish to Azure App Service, I get this nice ugly blue home page that I didn't make. No where in my project does this code exist, atleast that I can see in visual studio solution explorer. If I try to nagivate to <my account name>.azurewebsites.net/test I get a 404 error. Any suggestion?

应用。 py:

app.py:

from flask import Flask
app = Flask(__name__)

# Make the WSGI interface available at the top level so wfastcgi can get it.
wsgi_app = app.wsgi_app

@app.route('/test')
@app.route('/')
def hello():
    """Renders a sample page."""
    return "Hello World!"

if __name__ == '__main__':
    import os
    HOST = os.environ.get('SERVER_HOST', 'localhost')
    try:
        PORT = int(os.environ.get('SERVER_PORT', '5555'))
    except ValueError:
        PORT = 5555
    app.run(HOST, PORT)

web deploy.pubxml:

web deploy.pubxml:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <ResourceId>/subscriptions/78439574-998e-4216-b54c-40fa45d65ca5/resourceGroups/Default-SQL-EastUS/providers/Microsoft.Web/sites/FlaskWebProject220180702122411</ResourceId>
    <ResourceGroup>Default-SQL-EastUS</ResourceGroup>
    <PublishProvider>AzureWebSite</PublishProvider>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>http://flaskwebproject220180702122411.azurewebsites.net</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>flaskwebproject220180702122411.scm.azurewebsites.net:443</MSDeployServiceURL>
    <DeployIisAppPath>FlaskWebProject220180702122411</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>$FlaskWebProject220180702122411</UserName>
    <_SavePWD>True</_SavePWD>
    <_DestinationType>AzureWebSite</_DestinationType>
  </PropertyGroup>
</Project>

更新:

我遵循了以下步骤周杰伦列出。我现在收到由于发生内部服务器错误而无法显示该页面。。我在应用程序设置中添加了一个日志文件,但是它没有出现。

I followed the steps listed by Jay. I am now getting a "The page cannot be displayed because an internal server error has occurred.". I added a log file in the application setting, however, it does not appear.

UPDAtE 2

我注意到在我的web.config文件中版本是不同的,所以我更新了。

I noticed that in my from web.config the versions were different so i updated it. this allowed the logs.txt to be created.

  <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python364x64\python.exe|D:\home\Python364x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>

我仍然遇到500错误。

I am still getting a 500 error.

logs.txt:

logs.txt:

推荐答案

请参阅我的工作步骤,看看错误是否仍然出现。

Please refer to my work steps and see if the error still shows up.

步骤1:创建一个Azure Web应用并添加扩展程序(这里是Python 3.6.1 x64)

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

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

Step 2 : Publish your flask project and add the web.config.

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\Python361x64\python.exe|D:\home\Python361x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
    </handlers>
  </system.webServer>
</configuration>

如果部署成功,您可以在 KUDU中看到以下结构路径: D:\home\site\wwwroot>

If you deploy successfully, you could see following structure in the KUDU path: D:\home\site\wwwroot>.

如果要使用其他python软件包,请继续。

If you want to use additional python package, please go on.

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

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.

第4步:安装所需的任何软件包通过 python -m pip安装pyodbc

Step 4 : Install any packages you need via python -m pip install pyodbc

希望它对您有帮助。如有任何疑问,请告诉我。

Hope it helps you. Any concern ,please let me know.

更新

Update:

在我的步骤中,将内容复制到 https://bootstrap.pypa.io/get-pip.py 安装点子。它可以识别系统python版本,安装相应的python软件包。

In my steps, copy content in https://bootstrap.pypa.io/get-pip.py to install pip. It could identify the system python version, install the corresponding python package.

因此,您只需要运行命令 python -m pip install news3k 来安装 newspaper3k

So,you just need to run the command python -m pip install newspaper3k to install newspaper3k.

这篇关于找不到Azure烧瓶路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 16:03