Adding another route causes 404 on cloud deploy only
See original GitHub issueOriginally, In main.py there is a function named hello_world
@app.route('/')
def hello_world():
return 'Hello, World!'
I added another function below
@app.route('/hello')
def hello_path():
return "HELLO FROM PATH"
So the full script is as follows:
from flask import Flask
app = Flask(__name__)
app.debug = True
@app.route('/')
def hello_world():
return 'Hello, World!'
@app.route('/hello')
def hello_path():
return "HELLO FROM PATH"
if __name__ == '__main__':
app.run()
When I run this on my localhost both endpoints work correctly and return their respective strings. However, after deploying via git to my azure website, I can only get the response from xxx.azurewebsites.net/
to work correctly (returns “Hello, World!”). When I try and hit xxx.azurewebsites.net/hello
I get a 404 error.
I’m not sure why it only works with the default route in the cloud when everything works fine locally. Is this a setup issue? Is there anyway I can debug the routing issues on Azure?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Error 404: 4 Ways to Fix It - Hostinger
Error 404 is a response code, meaning the server could not locate the requested content. Check this article to learn 4 steps to...
Read more >404 on any route for Flask app deployed to Elastic Beanstalk
Have you tried hosting the app on a different port (just for testing it out) and allowing through the firewall?
Read more >Troubleshoot External HTTP(S) Load Balancing - Google Cloud
The backend unexpectedly closed its connection to the load balancer before the response was proxied to the client. This can happen if the...
Read more >How to Fix Error 404 Not Found on Your WordPress Site - Kinsta
Users then try to access the content at the old location and see a 404 page instead of the resource they were expecting....
Read more >404 Not Found firebasedeploy - Atlassian Community
The root cause can also be not in CLI only, but in google-cloud-functions configuration or hosting, but to investigate that in more detail,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hgirish solution worked for me as well, i.e., add the following to your web.3.4.config:
Adding System.Web and System.WebServer block to web.3.4.config from https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/app-service-web/web-sites-python-configure.md worked for me