-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
27 lines (17 loc) · 611 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Msg(BaseModel):
msg: str
@app.get("/")
async def root():
return {"message": "Hello World. Welcome to FastAPI!"}
@app.get("/path")
async def demo_get():
return {"message": "This is /path endpoint, use a post request to transform the text to uppercase"}
@app.post("/path")
async def demo_post(inp: Msg):
return {"message": inp.msg.upper()}
@app.get("/path/{path_id}")
async def demo_get_path_id(path_id: int):
return {"message": f"This is /path/{path_id} endpoint, use post request to retrieve result"}