by Devin Yang
(This article was automatically translated.)

Published - 3 years ago ( Updated - 3 years ago )

1. Installation
pip install fastapi uvicorn
2. Sample programs (of course, if possible, create a verticalenv to run.
from typing import Optional

from fastapi import FastAPI

app = FastAPI()

def read_root():
    return {"Hello": "World"}

def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}
On the host side, I will put it into the background execution, and use the following command in the bash environment:
nohup uvicorn main:app --reload --host &
If you want to stop I use the following command
killall uvicorn
 To view execution status, use the
tail -f nohup.out

Tags: python

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


The python version of the tirm command

Record how to use python's tirm command


Execute system commands with python

How do I execute system commands with Python, here is a simple example


Simple test python-thread function and parameters

Record, how to use thread to perform functions