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)