Bird
0
0

What is the issue with this Flask route for returning task status?

medium📝 Troubleshoot Q6 of 15
Flask - Background Tasks
What is the issue with this Flask route for returning task status?
@app.route('/check_status/<task_id>')
def check_status():
    statuses = {'a': 'done'}
    return statuses.get(task_id, 'pending')
AThe return statement should use <code>jsonify</code>
BThe route decorator syntax is incorrect
CThe dictionary <code>statuses</code> is empty
DThe function lacks the <code>task_id</code> parameter
Step-by-Step Solution
Solution:
  1. Step 1: Check function parameters

    The route URL expects a task_id parameter, but the function does not accept it.
  2. Step 2: Understand impact

    Without task_id parameter, the function will raise a TypeError when called.
  3. Final Answer:

    The function lacks the task_id parameter -> Option D
  4. Quick Check:

    Route params must match function args [OK]
Quick Trick: Route parameters must match function arguments [OK]
Common Mistakes:
MISTAKES
  • Ignoring missing function parameters
  • Assuming dictionary content causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes