我通过派发https://github.com/Azure-Samples/python-docs-hello-world的仓库来在azure Web应用程序上部署了一个简单的Flask应用程序
这是我的应用程序。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)
这是我的要求。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时得到的
关于出了什么问题的任何线索吗?
答案 0 :(得分:1)
表明您的代码未上传到门户网站。
请遵循此official document进行测试。
我使用了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。然后只需按照article创建部署凭证/资源组/服务计划/ Web应用程序
6。如果没有问题,请在git bash中将代码推送为天蓝色:
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之类的网站,