Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python flask application in Azure web app only showing default page

I have been struggling for days to deploy a Python web app with flask on Azure. But all I ever get is the default page.

This is the address: https://el-priser.azurewebsites.net/ This is my Github repo: https://github.com/Michaelgimm/energinet-elpris

I also tried with the azure guide for a test app, but it does the same.

The deployment is a success and I can see all the files when accessing through SSH via this link: https://el-priser.scm.azurewebsites.net/

Any ideas?

I haave tried everything I can think of. What I did expect to see was my app. In the structure of my app I have a main.py but placed the index.html in a folder called templates.

like image 407
michaelgimm Avatar asked Jan 21 '26 14:01

michaelgimm


1 Answers

I have tried to deploy your application to Azure web app through VScode.

I could deploy the application, but I was able to see only default page and few times it also led me to Application Error.

enter image description here

  • After many trials, I could figure out the resolution for this issue.

  • To run the deployed Flask application, we have to add few settings in the web app.

  • Go to your App service=> Settings =>Configuration =>Application Settings=> Click on Add new application settings and add the settings:

1. SCM_DO_BUILD_DURING_DEPLOYMENT=1
2. WEBSITES_CONTAINER_START_TIME_LIMIT=1800
3. WEBSITES_PORT=<port_number_of_your_application>

enter image description here

  • Go to General Settings in Configuration of your web app and add the startup command gunicorn --bind=0.0.0.0 main:app.

  • As your Flask app main module is main.py and the Flask app object in that file is named as app, use the above given Startup command.

enter image description here

  • Restart the web app after adding all these settings.
  • Now, you will be able to access your application (index and prices pages):

Response:

I could access both the index and prices pages as shown below:

enter image description here

enter image description here

like image 120
Pravallika KV Avatar answered Jan 24 '26 03:01

Pravallika KV