FastAPI Delete Request - 11

2022. 12. 22. 09:20·Develop/FastAPI
728x90
SMALL

1. Delete

  • 데이터 삭제

​

2. dictionary 정의

BOOKS = {
    'book_1': {'title':'Title One','author':'Author One'},
    'book_2': {'title':'Title Two','author':'Author Two'},
    'book_3': {'title': 'Title Three', 'author': 'Author Three'},
    'book_4': {'title': 'Title Four', 'author': 'Author Four'},
    'book_5': {'title': 'Title Five', 'author': 'Author Five'},
}

 

3. 함수 정의

  • @app.delete
  • book_name을 받아서 BOOKS의 키 값으로 제거
@app.delete("/{book_name}")
async def delete_book(book_name):
    del BOOKS[book_name]
    return f"Book {book_name} deleted."
 
 
    • BOOKS의 book_2의 키와 값이 없어진 BOOKS return
728x90
SMALL
저작자표시 비영리 변경금지 (새창열림)

'Develop > FastAPI' 카테고리의 다른 글

FastAPI BaseModel 생성 - 13  (0) 2022.12.22
FastAPI Path / Query Parameters 정리 - 12  (0) 2022.12.22
FastAPI Put Request - 10  (0) 2022.12.22
FastAPI Post Request - 09  (0) 2022.12.22
FastAPI Query Parameters - 08  (0) 2022.12.22
'Develop/FastAPI' 카테고리의 다른 글
  • FastAPI BaseModel 생성 - 13
  • FastAPI Path / Query Parameters 정리 - 12
  • FastAPI Put Request - 10
  • FastAPI Post Request - 09
동석해요
동석해요
공부하고 싶은게 많은, 사소한 IT 지식들 공유
    250x250
  • 동석해요
    개발로 자기계발
    동석해요
  • 전체
    오늘
    어제
    • 분류 전체보기 (226)
      • Develop (126)
        • 기초지식 (12)
        • FastAPI (102)
        • Django (11)
      • Database & Data (62)
        • 기초지식 (16)
        • MySQL (29)
        • PostgreSQL (8)
        • 데이터 분석 (9)
      • 인공지능 (11)
        • PyTorch (9)
      • Cloud (8)
        • AWS (4)
        • GCP (2)
      • 버그처리 (14)
      • 회고 & 일상 (5)
  • 인기 글

  • 최근 글

  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.3
동석해요
FastAPI Delete Request - 11
상단으로

티스토리툴바