Async Views in Flask 2.0
Flask 2.0, released in May 2021, supports async views via async def. Installing the flask[async] extra (which includes asgiref) is required. Async views run in a thread pool by default.
Example
python
from flask import Flask
import httpx
app = Flask(__name__)
@app.route('/data')
async def get_data():
async with httpx.AsyncClient() as client:
resp = await client.get('https://api.example.com/data')
return resp.json()
# pip install flask[async]
# flask run
