- FastAPI Tutorial
pip install fastapi
pip install uvicorn
Run following command:
- default host and port is
http://127.0.0.1:8000
uvicorn main:app --host <your_host_ip> --port <port> --reload
Go to http://<your_host_ip>:<port>
to view the page.
pip install fastapi
pip install uvicorn
Run following command:
http://127.0.0.1:8000
uvicorn main:app --host <your_host_ip> --port <port> --reload
Go to http://<your_host_ip>:<port>
to view the page.
from fastapi import FastAPI | |
app = FastAPI() | |
@app.get("/") | |
async def root(): | |
return {"message": "Hello World"} | |
@app.get("/1") | |
async def sub(): | |
return {"message": "sub 1"} | |
@app.get("/2") | |
async def sub(): | |
return {"message": "sub 2"} |