FastAPI (2) 썸네일형 리스트형 [SQLAlchemy] schema에 따라 객체 변형해서 담기 router 한땀한땀 넣기 # router # 별로 없을때, 한땀한땀 넣기 @router.get("/{report_id}", response_model=schemas.Report) def report_read(report_id:int): report = (db.query(models.report, models.user.name.label("writer")) .join(models.user, models.report.writer == models.id) .first()) return schemas.test( id=report.id, title=report.name, contents=report.contents, comment=schemas.childComment.from_orm(report.comment).. [Python] fastapi 파일 업로드 & data fastapi로 파일을 받고 json 데이터도 받고 싶었다. 근데 안된단다... 그걸 모르고 열심히 삽질했다. 422 Error value is not a valid dict FormData([('files', ), ( 'new_report', '{\r\n "name": "test.jpeg"\r\n,"owner": "test11"\r\n}')]) 안되는 이유는 아래와 같다. 다수의 File과 Form 매개변수를 한 경로 작동에 선언하는 것이 가능하지만, 요청의 본문이 application/json가 아닌 multipart/form-data로 인코딩 되기 때문에 JSON으로 받아야하는 Body 필드를 함께 선언할 수는 없습니다. 이는 FastAPI의 한계가 아니라, HTTP 프로토콜에 의한 것입니다. ht.. 이전 1 다음