3

in a recent article, https://www.vultr.com/docs/how-to-deploy-fastapi-applications-with-gunicorn-and-nginx-on-ubuntu-20-04/

I read that fastapi "can work with WSGI if needed". I was wondering how?

I did a whole project with fastapi and tried to deploy it on cpanel shared hosting(my option for the moment) ,

in the wsgi.py file I used a2sg library

from main import app
from a2wsgi import ASGIMiddleware
application = ASGIMiddleware(app)

but I get 503 temporary busy, try again when I browse to the page

so, how can I deploy my app , I deployed django with ease but fasapi is an issue as it mainly uses ASGI. is it also possible?

1 Answers1

1

There are few checks you need to do apart from adding the A2WSGI Middleware.

  1. Adding empty py files named as __init__.py in each directory including root of application

  2. Create new passenger.py file with same code you have given in wsgi.py

  3. Use the above passenger.py file while setting up the python application, also keep wsgi.py as you have prepared already in same directory. (Cpanel->Setup Python App)

  4. Run Uvicorn server with unused port like 60323 etc.

  5. Restart the app from the Python Application Options

S.B
  • 13,077
  • 10
  • 22
  • 49