...

Fastapi On Gunicorn

Frank Casanova

Oct. 13, 2023

...

the best way, put this code at the end of your main file:

 

if __name__ == "__main__":
    import subprocess
    command = ["gunicorn", "main:app", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000"]
    subprocess. Run(command)