首页 > 解决方案 > 部署的 Azure 烧瓶应用始终显示默认登录页面

问题描述

我通过从https://github.com/Azure-Samples/python-docs-hello-world分叉存储库在 azure webapp 上部署了一个简单的 Flask 应用程序

这是我的application.py

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"


@app.route("/sms")
def hello_sms():
    return "Hello World SMS!"


# if __name__ == '__main__':
#    app.run(debug = True)

这是我的 requirements.txt

click==6.7
Flask==1.0.2
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
Werkzeug==0.14.1

起初,当我打开 URL ( https://staysafe.azurewebsites.net/ ) 时,我收到了一条消息,“您要查找的资源已被删除、名称已更改或暂时不可用。” 之后,我何时在 azure 的 webapp 仪表板中进行应用程序设置并设置 python 版本。自从这就是我打开我的 URL 时得到的 打开网址

关于出了什么问题的任何线索?

标签: azureflaskweb-applicationsazure-web-app-serviceazure-webapps

解决方案


您的代码未上传到门户的接缝。

请按照此官方文档进行测试。

我使用了来自https://github.com/Azure-Samples/python-docs-hello-world的代码,并且工作正常。步骤如下:

环境:python3.7,windows 10

1.打开git bash,下载代码到本地使用git clone https://github.com/Azure-Samples/python-docs-hello-world.git

2.在git bash中,执行cd python-docs-hello-world

3.在git bash中,一一执行以下命令:

py -3 -m venv venv
venv/scripts/activate
pip install -r requirements.txt
FLASK_APP=application.py flask run

4.打开 Web 浏览器,并导航到http://localhost:5000/处的示例应用程序。

这是为了确保它可以在本地正常工作。

5.然后按照文章创建部署凭据/资源组/服务计划/Web应用程序

6.如果没有问题,在git bash中,将代码推送到azure:

git remote add azure <deploymentLocalGitUrl-from-create-step>

然后执行git push azure master

7.浏览到https://your_app_name.azurewebsites.nethttps://your_app_name.azurewebsites.net/sms等网站,

效果很好,截图如下: 在此处输入图像描述


推荐阅读