简体   繁体   中英

How do I deploy a FastAPI application on cPanel?

I'm trying to deploy FastAPI application on cPanel, but I am clueless to start Uvicorn. 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM