Python / Uvicorn Fundamentals Interview Questions
What is Uvicorn's --interface flag and what application types does it support?
The --interface flag tells Uvicorn which application protocol to expect. The default auto setting detects the interface automatically, but you can force a specific mode.
| Value | Interface | WebSocket support | Notes |
|---|---|---|---|
| auto (default) | Auto-detect ASGI3, ASGI2, or WSGI | If ASGI | Recommended for most cases |
| asgi3 | ASGI 3.0 (current standard) | Yes | Explicit ASGI3 |
| asgi2 | ASGI 2.0 (legacy double-callable) | Yes | Legacy - rarely needed |
| wsgi | WSGI (synchronous) | No | Always disables WebSocket support |
# Auto-detect (default - recommended) uvicorn main:app --interface auto # Explicit ASGI3 (FastAPI, Starlette, modern frameworks) uvicorn main:app --interface asgi3 # WSGI mode (for Django without channels, Flask) uvicorn main:app --interface wsgi # WARNING: WSGI mode disables WebSocket support entirely # Programmatic: uvicorn.run("main:app", interface="asgi3")
WSGI mode deprecation note: Uvicorn's native WSGI implementation is deprecated. For running WSGI applications through Uvicorn, you should use the a2wsgi adapter (pip install a2wsgi) which wraps your WSGI app in an ASGI-compatible interface. This approach keeps the full ASGI pipeline while supporting legacy WSGI apps.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
