[FastAPI] RestAPI 사용하기

김시환·2022년 11월 8일
0

FastAPI

목록 보기
2/3
from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def read_item():
    return {"RESTAPI": "get"}

@app.post("/")
async def read_item():
    return {"RESTAPI": "POST"}

@app.put("/{item_id}")
async def read_item(item_id: int):
    return {"item_id": "updated "+str(item_id)}

@app.delete("/{item_id}")
async def read_item(item_id: int):
    return {"item_id": 'deleted ' + str(item_id)}

GET

POST

PUT

Delete

profile
파이팅!

0개의 댓글