Shanmukha
Shanmukha

Reputation: 2574

Python app not able to access from azure app services

I have deployed a Python app to Azure app service (OS: Linux, Python) from Visual Studio Code. I can able to see the files in the wwwroot folder as well as in the app service, but when I am trying to access the app service by URL, the login page not displayed. Please refer to the code below:

from flask import *

app=Flask(__name__)

@app.route('/')
def welcome():
    return render_template("login_post.html")

"""using POST request method"""
@app.route('/login',methods=["POST"])
def login():
    uname=request.form["uname"]
    password=request.form["pass"]

    if uname=="shannu" and password=="guru":
        return "Welcome %s"%uname
    
if __name__=='__main__':
    app.run()

Refer to the screenshot for files under wwwroot folder (in app service):
Index of /wwwroot/ directory

Not sure is there anything am I missing here. Thanks in advance.

Upvotes: 0

Views: 736

Answers (1)

Jason Pan
Jason Pan

Reputation: 21883

You need add startup command.

gunicorn --bind=0.0.0.0 --timeout 600 app:app

Offical doc:

Flask app--Startup command

Suggestion

If this command not useful to you, it is recommand you deploy your flask app by vscode.

enter image description here

enter image description here

You will find azure web app will auto generate gunicorn command for 'app:app'.

enter image description here

Upvotes: 1

Related Questions