why can't I access flask app root URL from my web app?

sumant bhandari 0 Reputation points
2024-03-13T05:01:52.0533333+00:00

I have a deployed application that seems to be functioning correctly. Upon inspecting the shell logs, I can confirm that the app is running and listening on the specified port. It's also successfully handling incoming requests. However, I'm encountering an issue where the root URL is not functioning as expected. Interestingly, the same code works flawlessly when run locally. I've checked the traffic settings, and there don't appear to be any restrictions in place. I'm perplexed as to why this discrepancy exists. Any assistance in troubleshooting this matter would be greatly appreciated.

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Deepanshukatara-6769 16,565 Reputation points Moderator
    2024-03-13T05:56:31.19+00:00

    Hi,

    It seems like the static files are not being served properly.Ensure that you have defined a route for the root URL ("/") in your Flask application. This is typically done using the @app.route('/') decorator in your Flask application code.

    Here's an example:

    from flask import Flask
    
    app = Flask(__name__)
    
    @app.route('/')
    def index():
        return 'Hello, World!'
    
    if __name__ == '__main__':
        app.run()
    
    

    Once you have made the changes, you can redeploy your app and try accessing the image again.

    Let me know if this helps!

    Reference: https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#serve-static-files-for-flask-apps


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.