azure - 部署的 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 时得到的
关于出了什么问题的任何线索?
解决方案
您的代码未上传到门户的接缝。
请按照此官方文档进行测试。
我使用了来自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.net或https://your_app_name.azurewebsites.net/sms等网站,
推荐阅读
- mysql - 如何为重新测试记录创建模式?
- python - 在 PyTorch 中计算加权平均值
- c++ - OpenCV C++ 中的位移
- javascript - Mongoose Model.Create 和 Model.Update 另一个
- flutter - 颤振在可选功能执行后仅重置自定义小部件状态
- c - 与插件机制一起使用的 C struct malloc/free 的 Fortran 等价物
- localization - Blazor 服务器 - 运行 dotnet publish --configuration release 时输出文件夹中缺少本地化 dll (xxx.resources.dll)
- c++ - 如何将 dynamic_pointer_cast 与可变参数模板一起使用?
- algorithm - 国际象棋编程:极小极大、检测重复、转置表
- android - Android中的布局编辑器显示嵌入画布元素的位置和形状错误