0
0
Flaskframework~20 mins

Task status monitoring in Flask - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Task Status Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Check Flask task status endpoint output
Given a Flask app with a background task status endpoint, what is the output when the task is still running?
Flask
from flask import Flask, jsonify
app = Flask(__name__)
tasks = {'task1': 'running'}

@app.route('/status/<task_id>')
def status(task_id):
    state = tasks.get(task_id, 'not found')
    return jsonify({'task_id': task_id, 'status': state})

# Request: GET /status/task1
A{"task_id": "task1", "status": "running"}
B{"task_id": "task1", "status": "completed"}
C{"task_id": "task1", "status": "failed"}
D{"task_id": "task1", "status": "not found"}
Attempts:
2 left
💡 Hint
Check the tasks dictionary for the status of 'task1'.
Configuration
intermediate
2:00remaining
Configure Flask to run background tasks with status tracking
Which Flask extension and configuration is best suited to run background tasks and monitor their status?
AUse Flask-Mail to send task status emails
BUse Flask-Celery with Redis broker to run tasks and track status
CUse Flask-SocketIO with eventlet for real-time task status updates
DUse Flask-Login to authenticate task status requests
Attempts:
2 left
💡 Hint
Look for a task queue system integrated with Flask.
Troubleshoot
advanced
2:00remaining
Troubleshoot missing task status updates in Flask app
A Flask app using Celery to run tasks does not update task status correctly. Which issue is most likely causing this?
ARedis server is running but not connected to Flask app
BFlask app is missing @app.route decorators
CThe Celery worker is not running, so tasks never execute
DFlask debug mode is off
Attempts:
2 left
💡 Hint
If tasks never run, status won't update.
🔀 Workflow
advanced
3:00remaining
Order the steps to implement task status monitoring in Flask
Arrange these steps in the correct order to implement task status monitoring in a Flask app using Celery.
A1,3,2,4
B2,1,4,3
C3,1,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Setup first, then task, then status route, then run worker.
Best Practice
expert
3:00remaining
Choose the best practice for scalable task status monitoring in Flask
Which approach is best for scalable and reliable task status monitoring in a Flask app with many concurrent tasks?
AUse a persistent external store like Redis or database to save task status
BLog task status only to Flask console logs
CSend task status updates via email to users
DStore task status in Flask app memory (global variable) for quick access
Attempts:
2 left
💡 Hint
Think about multiple workers and app instances.