Need steps to deploy python flask application and run it from __main__()

Maniratha Goud Kunoor 1 Reputation point
2021-10-31T07:10:18.237+00:00

I have deployed a flask application on Ubuntu Server on azure. The application seems to be serving the pages but it is not executing the code in the main() function. I require the application to execute the code in main() function too.

Please help me running the application as describe above.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,844 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 25,481 Reputation points Microsoft Employee
    2021-11-01T22:49:49.213+00:00

    Hi @Maniratha Goud Kunoor ,

    To get your app to run __main__(), you can set the startup parameter to the python module containing the function. For example, if your main sub is in main.py, then you will set gunicorn -bind=0.0.0.0 main:app as the startup parameter for your app service.

    You can read more about configuring the startup for your Python application on https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#container-startup-process