3

I'm trying to deploy FastAPI application on cPanel, but I am clueless to start Unicorn. Below is my main.py file code.

from fastapi import FastAPI

app = FastAPI()

@app.get('/')
async def root():
    return {"message": "Hello World"}

@app.get('/items')
async def get_items():
    return {"apples": 3, "oranges": 5}

And this is my passenger_wsgi.py file code:

import imp
import os
import sys


sys.path.insert(0, os.path.dirname(__file__))

wsgi = imp.load_source('wsgi', 'main.py')
application = wsgi.app
Jitendra
  • 461
  • 6
  • 15
  • https://stackoverflow.com/a/65147451/7530362 might help you – pypae Dec 04 '20 at 20:28
  • did you ever solve this? I am now running into a similar problem here https://stackoverflow.com/questions/73369118/failure-to-get-fastapi-working-with-cpanel-using-a2wsgi – mdkb Aug 16 '22 at 05:28

1 Answers1

2

Passenger at the moment only supports WSGI. FastAPI uses ASGI, so it's not possible to deploy it on Passenger at the moment. There is an open issue to support ASGI apps on passenger.

saroj
  • 41
  • 2