Skip to content

Route Not Found (404) Error for Root URL /  #1

@ericBlack1

Description

@ericBlack1

Description:
When running the provided Flask application, accessing the root URL http://127.0.0.1:5000/ returns a 404 Not Found error. However, the /home route works as expected.

Steps to Reproduce:

  1. Run the Flask application using the provided code snippet.
  2. Open a web browser and navigate to http://127.0.0.1:5000/.
  3. Observe the 404 Not Found error.
  4. Navigate to http://127.0.0.1:5000/home, which works as intended.

Expected Behavior:
The root URL / should display content or redirect to /home.

Actual Behavior:
The root URL / returns a 404 Not Found error.

Code Snippet:

from flask import Flask

app = Flask(__name__)

@app.route('/home')
def home():
    return "Welcome to your first Flask application!"

if __name__ == '__main__':
    app.run(debug=True)

Development Environment:

  • OS: Ubuntu 24.04.
  • Python Version: 3.12.3
  • Flask Version: 3.0.3

Suggested Fix:
Add a route for / to handle root URL requests. For example:

@app.route('/')
def index():
    return "Welcome to the root URL!"

Let me know if you would like any additional details or clarifications.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions