Bird
0
0

Which of the following is the correct way to define an async route in Flask?

easy📝 Syntax Q12 of 15
Flask - Ecosystem and Patterns
Which of the following is the correct way to define an async route in Flask?
Aasync def async_route(): return 'Hello'
Bdef async_route(): return 'Hello'
Casync def async_route(): await return 'Hello'
Ddef async_route(): await 'Hello'
Step-by-Step Solution
Solution:
  1. Step 1: Recall async function syntax

    Async functions start with async def and can use await inside.
  2. Step 2: Check each option

    async def async_route(): return 'Hello' correctly defines an async function returning a string. def async_route(): return 'Hello' is sync. async def async_route(): await return 'Hello' misuses await with return. def async_route(): await 'Hello' uses await outside async.
  3. Final Answer:

    async def async_route(): return 'Hello' -> Option A
  4. Quick Check:

    Async function = async def [OK]
Quick Trick: Async routes start with 'async def' keyword [OK]
Common Mistakes:
MISTAKES
  • Using await outside async functions
  • Trying to await a return statement
  • Defining async routes without async def

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes