python-3.xstarlettehypercorn

How to interface hypercorn and starlette web framwork


I was able to get it up and running with gunicorn and uvloop, but having a hard time getting this working with hypercorn. Another issue is specifying the number of workers for ASGI frameworks.


Solution

  • You probably have a line like app = Starlette(debug=True) the app is an ASGI application that can be run by Hypercorn (or other ASGI servers). If this line is in a file called run.py you can run it via hypercorn run:app.

    If you want multiple workers (2 shown) you can do hypercorn -w 2 run:app. If you want uvloop as well, hypercorn -w 2 -k uvloop run:app.