Sobes.tech
Middle

What ASGI servers do you know?

sobes.tech AI

Answer from AI

  • Uvicorn: A high-performance, asynchronous ASGI server built on uvloop and h11. Often used with FastAPI and Starlette.
  • Hypercorn: An ASGI server compatible with HTTP/1, HTTP/2, and Quart. Supports multiple backends, including asyncio, uvloop, and trio.
  • Daphne: The first ASGI server developed for Django Channels. Less performant compared to Uvicorn and Hypercorn in general cases, but well integrated with the Django ecosystem.
# Example of running Uvicorn
# import uvicorn
#
# async def app(scope, receive, send):
#     assert scope['type'] == 'http'
#     await send({
#         'type': 'http.response.start',
#         'status': 200,
#         'headers': [[b'content-type', b'text/plain'],],
#     })
#     await send({
#         'type': 'http.response.body',
#         'body': b'Hello, world!',
#     })
#
# if __name__ == '__main__':
#     uvicorn.run(app, host='127.0.0.1', port=8000)