0

I have deployed a simple Flask application on an azure webapp by forking the repo from https://github.com/Azure-Samples/python-docs-hello-world

Here is my 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)

And this is my requirements.txt

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

At first when I opened the URL ( https://staysafe.azurewebsites.net/ ) i got this message, "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." After which i when to the application settings in the webapp dashboard in azure and set a python version. And ever since this is what I get when i open my URL open url

Any clue as to what is going wrong?

Shobhit Kumar
  • 626
  • 1
  • 5
  • 21
  • have you created an virtual environment? – Ivan Glasenberg Oct 16 '18 at 09:02
  • No. is it required to run in on the webapp? – Shobhit Kumar Oct 16 '18 at 09:25
  • no, it not required. But I recommend to use it for ignoring something missing. You can follow this official [article](https://learn.microsoft.com/en-us/azure/app-service/containers/quickstart-python), I used your code, and works fine. – Ivan Glasenberg Oct 16 '18 at 09:32
  • I had the same problem where logs are saying everything is correct but still getting the default page. The problem is the ending "/" in url. My firefox was removing the ending "/" in the url but it works fine with internet explorer. https://xyz.azurewebsites.net/ – vks2106 Nov 11 '19 at 15:30

1 Answers1

1

Seams that your code is not uploaded to portal.

Please follow this official document for your test.

I Used your code from https://github.com/Azure-Samples/python-docs-hello-world, and works fine. The steps as below:

Environment: python3.7, windows 10

1.Open git bash,download the code to local using git clone https://github.com/Azure-Samples/python-docs-hello-world.git

2.In git bash, execute cd python-docs-hello-world

3.In git bash, execute following command one by one:

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

4.Open a web browser, and navigate to the sample app at http://localhost:5000/ .

It is to make sure it can work well in local.

5.Then just follow the article to create deployment credetial / resource group / service plan / a web app

6.If no issues, in git bash, push the code to azure:

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

Then execute git push azure master

7.Browse to the website like https://your_app_name.azurewebsites.net, or https://your_app_name.azurewebsites.net/sms,

it works fine, screenshot as below: enter image description here

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60