Bird
0
0

You wrote this Flask route but get a 404 error:

medium📝 Debug Q6 of 15
Flask - Ecosystem and Patterns
You wrote this Flask route but get a 404 error:
@app.route('/home')
def homepage():
    return 'Welcome'

What is a likely cause?
AYou forgot to import Flask
BYou accessed the URL /homepage instead of /home
CFlask requires routes to be uppercase
DThe function name must be 'home' to match the route
Step-by-Step Solution
Solution:
  1. Step 1: Check route URL vs accessed URL

    The route is '/home', so accessing '/homepage' causes 404.
  2. Step 2: Understand function name irrelevance

    Function name does not affect URL routing in Flask.
  3. Final Answer:

    You accessed the URL /homepage instead of /home -> Option B
  4. Quick Check:

    Route URL must match accessed URL exactly [OK]
Quick Trick: Access exact route URL to avoid 404 [OK]
Common Mistakes:
MISTAKES
  • Assuming function name affects URL
  • Thinking routes must be uppercase
  • Ignoring import errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes