Bird
0
0

What response will this async Flask route return when accessed?

medium📝 component behavior Q4 of 15
Flask - Ecosystem and Patterns
What response will this async Flask route return when accessed?
from flask import Flask
import asyncio
app = Flask(__name__)

@app.route('/greet')
async def greet():
    await asyncio.sleep(0.2)
    return 'Hello from async'
AA JSON response with status code 200
BAn immediate empty response
CA runtime error due to missing await
DThe string 'Hello from async' after a short delay
Step-by-Step Solution
Solution:
  1. Step 1: Analyze async route

    The route awaits a 0.2 second sleep asynchronously.
  2. Step 2: Return value

    After the delay, it returns the string 'Hello from async'.
  3. Final Answer:

    The string 'Hello from async' after a short delay -> Option D
  4. Quick Check:

    Await causes delay, then returns string [OK]
Quick Trick: Async sleep delays response, then returns string [OK]
Common Mistakes:
MISTAKES
  • Expecting immediate response ignoring await
  • Confusing return types with JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes