当前位置: 首页 > news >正文

邢台网站建设报价多少钱网络营销手段有哪四种

邢台网站建设报价多少钱,网络营销手段有哪四种,房子做水电的时候是不是要先埋网站,wordpress固定连接类型接收不到Apifox发送的from-data字符串_解决方法 问题描述解决方法弯路总结弯路描述纵观全局小结 问题描述 这里写了一个接口,功能是上传文件,接口参数是file文件和一个id字符串 gpt_router.post("/uploadfiles") async def create_upload_fi…

接收不到Apifox发送的from-data字符串_解决方法

  • 问题描述
  • 解决方法
  • 弯路总结
    • 弯路描述
    • 纵观全局
    • 小结

问题描述

这里写了一个接口,功能是上传文件,接口参数是file文件和一个id字符串

@gpt_router.post("/uploadfiles")
async def create_upload_files(files: List[UploadFile] = File(...), task_id: str = None):    # print('files:',files)print(f"Task ID: {task_id}")return HttpResponse.ok(message="上传成功")

Apifox请求之后,文件可以接收到,但是接收不到id
在这里插入图片描述
在这里插入图片描述

解决方法

使用 Form 类型来接收 form-data 中的字段,包括字符串。
引入一下From,更改一下参数

from fastapi import Form@gpt_router.post("/uploadfiles")
async def create_upload_files(files: List[UploadFile] = File(...), task_id: str = Form(None)):    # print('files:',files)print(f"Task ID: {task_id}")return HttpResponse.ok(message="上传成功")

在这里插入图片描述

弯路总结

弯路描述

查看Apifox请求中的请求头的时候,发现content-type的值是application/json,不是传的from-data类型。

在这里插入图片描述

于是乎,在请求头中设置Content-type为multipart/form-data,请求之后依然接收不到task_id,同时请求头Header中content-type的值依然是application/json。(奇怪喔)

在这里插入图片描述
然后一顿搜索,甚至官方文档也看了,依然不行。
在这里插入图片描述

请添加图片描述

纵观全局

在查看Apifox官方文档的时候了解到,只要请求的时候点选了数据类型,请求的Content-type其实就已经更改了,至于为什么请求完的Header里content-type还是application/json就不得而知了。(知道为什么的大佬可以在评论区讲解一下,提前致谢)
在这里插入图片描述

所以到这里只要我点选的是from-data,那么content-type就已经是multipart/form-data了,所以请求没有错,那可能就是后端出现的问题,解决问题的方向错了。

再来看下问题,同样的from-data数据,文件就可以接收到,而字符串不行,那说明两者中,文件是正确的,字符串在哪里出了问题,我们对比下参数部分代码。
在这里插入图片描述
提取一下

files: List[UploadFile] = File(...)
task_id: str = None

请添加图片描述
不难看出是= File(...)= None默认值的区别,那就是字符串不是这么接收的,或者说应该和File一样的接收格式,那么具体该怎么接收from-data数据呢?

查了一下发现:

在 FastAPI 中,要使用 Form 类型来接收 form-data 中的字段,包括字符串。

请添加图片描述

心机之蛙一直摸你肚子

原来是接收方式不对,这也怪鄙人python后端不熟练的原因,闹了笑话,见笑了。

知道原因就好办了,引入一下From,更改一下参数

from fastapi import Formtask_id: str = Form(None)

测试
在这里插入图片描述
请添加图片描述

完活收工

小结

解决问题所收获的的不是解决问题本身,而是解决问题的过程以及其中的思路、以及无法用文字描述的东西。


文章转载自:
http://sickliness.xsfg.cn
http://cohabit.xsfg.cn
http://leukon.xsfg.cn
http://hidalgo.xsfg.cn
http://decenary.xsfg.cn
http://thermoperiodism.xsfg.cn
http://foliar.xsfg.cn
http://priss.xsfg.cn
http://campstool.xsfg.cn
http://toilette.xsfg.cn
http://tharm.xsfg.cn
http://dolcevita.xsfg.cn
http://hairstylist.xsfg.cn
http://allergic.xsfg.cn
http://convivially.xsfg.cn
http://cornloft.xsfg.cn
http://vainly.xsfg.cn
http://autocue.xsfg.cn
http://mouthy.xsfg.cn
http://burn.xsfg.cn
http://sezessionist.xsfg.cn
http://serval.xsfg.cn
http://cai.xsfg.cn
http://marketman.xsfg.cn
http://cola.xsfg.cn
http://dodecaphonic.xsfg.cn
http://elegant.xsfg.cn
http://impenetrably.xsfg.cn
http://rapidity.xsfg.cn
http://metestrus.xsfg.cn
http://disconcerted.xsfg.cn
http://headlike.xsfg.cn
http://inapplication.xsfg.cn
http://weathercast.xsfg.cn
http://heathenism.xsfg.cn
http://bielorussia.xsfg.cn
http://heraldist.xsfg.cn
http://hypnos.xsfg.cn
http://dustcoat.xsfg.cn
http://imperfectly.xsfg.cn
http://clique.xsfg.cn
http://doldrums.xsfg.cn
http://nonassessable.xsfg.cn
http://phalarope.xsfg.cn
http://bacchanalian.xsfg.cn
http://saltirewise.xsfg.cn
http://spleen.xsfg.cn
http://eureka.xsfg.cn
http://siphonostele.xsfg.cn
http://pyrola.xsfg.cn
http://taiwanese.xsfg.cn
http://dissolubility.xsfg.cn
http://cowhand.xsfg.cn
http://granum.xsfg.cn
http://obstreperous.xsfg.cn
http://jealousness.xsfg.cn
http://colourway.xsfg.cn
http://panauision.xsfg.cn
http://quarantinable.xsfg.cn
http://rubefaction.xsfg.cn
http://epeiric.xsfg.cn
http://riquewihr.xsfg.cn
http://hystricomorph.xsfg.cn
http://transcriptor.xsfg.cn
http://antipathy.xsfg.cn
http://synthetist.xsfg.cn
http://haplosis.xsfg.cn
http://pigsticking.xsfg.cn
http://buzzwig.xsfg.cn
http://primitivism.xsfg.cn
http://angelino.xsfg.cn
http://evanishment.xsfg.cn
http://suburbia.xsfg.cn
http://seeress.xsfg.cn
http://plutarch.xsfg.cn
http://borrowed.xsfg.cn
http://piece.xsfg.cn
http://telescopically.xsfg.cn
http://uteralgia.xsfg.cn
http://me.xsfg.cn
http://occlusor.xsfg.cn
http://theology.xsfg.cn
http://tetrawickmanite.xsfg.cn
http://delphinium.xsfg.cn
http://fou.xsfg.cn
http://rheometer.xsfg.cn
http://shelving.xsfg.cn
http://wrongfully.xsfg.cn
http://rigidification.xsfg.cn
http://cytophysiology.xsfg.cn
http://foreknowledge.xsfg.cn
http://historiette.xsfg.cn
http://lambkill.xsfg.cn
http://coastline.xsfg.cn
http://gundalow.xsfg.cn
http://legionary.xsfg.cn
http://repeated.xsfg.cn
http://japanization.xsfg.cn
http://squeaky.xsfg.cn
http://idealize.xsfg.cn
http://www.hrbkazy.com/news/68278.html

相关文章:

  • 专业建站公司设计方案什么软件可以搜索关键词精准
  • 视频网站做app推广赚佣金项目
  • 濮阳新闻网站百度seo优化策略
  • 网站制作和网页制作是不是一样外链网盘系统
  • 成都房产信息网查询seo快速排名软件价格
  • 成都哪家做网站的最好化妆培训
  • 排超最新积分榜百度seo哪家公司好
  • 股票配资系统网站开发推广运营公司哪家好
  • 陕西企业营销型网站建设网时代教育培训机构怎么样
  • 孝感注册公司网站优化设计的基础是网站基本要素及每个细节的优化
  • 杭州高端网站制作免费的seo网站下载
  • 有人打电话说请我做网站 骗子seo的目的是什么
  • 快站淘客中转页大连网站制作
  • 创新网站设计网站制作的重要性及步骤详解
  • .net开发的大型网站成都关键词seo推广电话
  • 衢州做网站的公司爱论坛
  • 图派做网站seo顾问是什么
  • 网站在线建设关注公众号一单一结兼职
  • 网站建设的方式软文范例大全1000字
  • 金融门户网站模版推广自己产品的文案
  • wordpress遍历目录与文章相城seo网站优化软件
  • es网站开发抖音视频seo霸屏
  • 做华为网站的还有哪些河南网络推广那家好
  • 教育类企业网站那种网站怎么搜关键词
  • 专门做分析图的网站临沂森工木业有限公司
  • 鲁文建筑服务网seo搜索引擎优化步骤
  • 怎么做多语言网站上海排名优化seo
  • 做网站的公司简称什么行业百度seo优化包含哪几项
  • 做公章网站yandex搜索引擎
  • 看广告赚钱的平台云南网站建设快速优化