我想在后端读取这个 xlsx 文件。当我使用 swagger 时,我得到了它,但是当我在前端测试时,我收到错误 422 - devtools/网络详细信息'': ( ( loc'':(body file msg'':field required'', type'': value_error 丢失)))。
router = APIRouter()
@router.post('/')
async def upload_file(file: Uploadfile = File(...)):
try:
arquivo = await file.read()
df_cambio = pd.read_excel(arquivo)
cambio_dict = df_cambio.to_dict('index')
print(cambio_dict)
return{"file_name": file.filename}
except Exception as e:
exception_handler(e)
Run Code Online (Sandbox Code Playgroud)
反应->
export defaut function Dropzone() {
const [create, {isLoading}] = usePost();
const handleSubmit = (res) => {
create('cambios', { data:res.file }})
};
if (isLoading) { return <LoadingPageSkeleton />;}
return (
<BasicForm
initialValues={{}}
onSubmit={handleSubmit}
> …Run Code Online (Sandbox Code Playgroud)