
[FastAPI] 응답 모델
·
Programming/Python
FastAPI 목차 FastAPI 소개 FastAPI 설치 경로 매개변수 쿼리 매개변수 요청 본문 응답 모델 모든 경로 작업에서 response_model 매개 변수를 사용하여 반응에 사용되는 모델을 선언할 수 있습니다. from typing import Optional from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class User(BaseModel): name: str password: str @app.post("/users", response_model=User) #응답 모델 def create_user(user: User): #요청 모델 return user 해당 코드를 작성하고 "http://localhos..