当前位置:网站首页>19_ Request forms and documents
19_ Request forms and documents
2022-07-26 02:12:00 【Empty nest youth_ rui】
19_ Request forms and documents
We can use... At the same time File and Form Define file and form fields .
explain : Receive uploaded file or form data , To pre install
python-multipartmodular .
Definition File and Form Parameters
Use the same method as before to create File and Form Parameters :
from fastapi import FastAPI, File, Form, UploadFile
app = FastAPI()
@app.post("/files/")
async def create_file(
file: bytes = File(), fileb: UploadFile = File(), token: str = Form() # At the same time define File and Form Parameters
):
return {
"file_size": len(file),
"token": token,
"fileb_content_type": fileb.content_type,
}
Files and form fields will be uploaded by users as form data , Then we receive .
meanwhile , We can also declare some files as bytes, The other part is declared as UploadFiles.
Warning :
We can declare multiple in one path operation
FileandFormParameters , however , Cannot declare to receive at the same time JSON OfBodyField .Because the code of the request body is
multipart/form-data, instead ofapplication/json.This is a HTTP Provisions of the agreement , No FastAPI The problem of .
边栏推荐
- CD from grabbing the track to building a streaming media server -- a case study of "moon in the hometown of sleep"
- Quick start of adding, deleting, modifying and checking business
- c# 单元测试
- 本地仓库导致的报错
- Error reporting caused by local warehouse
- Worthington核酸酶、微球菌相关研究及测定方案
- [C language brush leetcode] 735. Planetary collision (m)
- Postman reported JSON serialization error
- QT program beautification of the use of style sheets, QT uses pictures as the background and transparency of controls, QT custom button styles
- National standard gb28181 protocol video platform easygbs message pop-up mode optimization
猜你喜欢

# Dest0g3 520迎新赛(更新中)

【2021】【论文笔记】6G技术愿景——OTFS调制技术

I.MX6UL核心模块使用连载-USB接口测试 (六)

prometheus+blackbox-exporter+grafana 监控服务器端口及url地址

Tenant issues.

Design and driver transplantation of matrix keyboard circuit of Ti am335x industrial control module

Ti am335x industrial control module uses the Debian system of beaglebone (BBB)

A pluggable am335x industrial control module onboard WiFi module

【2020】【论文笔记】磁控溅射法生长Bi2Te3/CoFeB双层异质结——

Video game quiz? I think it's useless. It's better to do these well!
随机推荐
[2021] [paper notes] 6G technology vision - otfs modulation technology
Detailed explanation of redis6.x configuration parameters
I.MX6UL核心模块使用连载-TF卡读写测试 (五)
一种MCU事件型驱动C框架
Dqn pytoch example
Acwing 379. hide and seek problem solution (minimum path non repeating point coverage)
i.MX6ULL SNVS电源域GPIO状态保持验证
数仓:浅谈银行业的数仓构建实践
A MCU event driven C framework
1. Mx6ul core module uses serial NAND FLASH read / write test (III)
[C language brush leetcode] 814. Binary tree pruning (m)
【2021】【论文笔记】红外及THz下的细胞膜生物效应——效应是现象,作用是机理——THz对医学的好处
Ti AM335X工控模块矩阵键盘电路的设计与驱动移植
商业智能BI全解析,探寻BI本质与发展趋势
MPLS知识点
1. Mx6ul core module serial USB interface test (VI)
# Dest0g3 520迎新赛(更新中)
[2019] [paper notes] tunable THz broadband absorption based on metamaterials——
Web3.0 blog DAPP development practice [2022]
SQL manual blind injection and error reporting injection