【问题标题】:How do I deploy a FastAPI application on cPanel?如何在 cPanel 上部署 FastAPI 应用程序?
【发布时间】:2021-03-16 04:30:44
【问题描述】:

我正在尝试在 cPanel 上部署 FastAPI 应用程序,但我无法启动 Unicorn。 下面是我的 ma​​in.py 文件代码。

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}

这是我的 passenger_wsgi.py 文件代码:

import imp
import os
import sys


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

wsgi = imp.load_source('wsgi', 'main.py')
application = wsgi.app

【问题讨论】:

标签: python python-3.x api cpanel fastapi


【解决方案1】:

Passenger 目前只支持 WSGI。 FastAPI 使用 ASGI,因此目前无法将其部署在Passenger 上。在乘客上支持 ASGI 应用程序存在一个未解决的问题。

【讨论】:

    猜你喜欢
    • 2021-03-14
    • 2020-05-17
    • 1970-01-01
    • 2019-10-18
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2020-01-04
    • 2019-10-12
    相关资源
    最近更新 更多