by Devin Yang

建立于: 3年前 ( 更新: 3年前 )

一、安装
pip install fastapi uvicorn
二、范例进程(当然如果可以的话创建vertualenv来跑罗。
from typing import Optional

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}
主机端,我会放入背景运行,在bash环境使用如下命令:
nohup uvicorn main:app --reload --host 0.0.0.0 &
如果要停止我用如下命令
killall uvicorn
 查看运行状态,用
tail -f nohup.out
 

Tags: python

Devin Yang

文章内容无法一一说明,如果您有什么不了解处,欢印提问哦:)

No Comment

Post your comment

需要登入才可留言!

类似文章


linux, python, colab

如何从我们的Server透过ssh连线到colab?

介绍我写的一支bash,用来透过ssh连线到colab vm内。 一行命令,搞定colab OpenSSH Server。

python

Macos运行Python出现certificate verify处理

我运行python时,出错的笔记

python

简单测试python-thread功能及参数

日志,如何使用thread运行功能