fastapi form data with pydantic model

前端 未结 3 711
滥情空心
滥情空心 2020-12-16 07:38

I am trying to submit data from html forms and on the validate it with pydantic model.
Using this code

from fastapi import FastAPI, Form
from pydantic im         


        
3条回答
  •  误落风尘
    2020-12-16 08:13

    you can use data-form like below:

    @app.post("/form", response_model=SimpleModel)
    def form_post(no: int = Form(...),nm: str = Form(...)):
        return SimpleModel(no=no,nm=nm)
    

提交回复
热议问题