Skip to content

使用腾讯云轻量应用服务器和宝塔面板搭建FastAPI

Published: at 09:14 AM

1. 编写基于FastAPI的main.py文件

import uvicorn
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def sayHi():
    return {"message":"Hello world!"}

# 启动uvicorn服务,默认端口8000,main对应文件名
if __name__ == '__main__':
    uvicorn.run('main:app')