在使用flask处理一些接口高并发的问题时候,发现响应没那么快,之后在网上了解到了FastAPI这个框架.在使用flask的post请求的原接口切换到fastapi接口的时候遇到"There was an error parsing the body"问题,有以下两种处理方案
pip install uvicorn
pip install fastapi
pip install python-multipart
1.更改原接口
# Read the body of the request as JSON
# session.post(url, data=data)
session.post(url, json=data)
# -*- coding: utf-8 -*-
# @Time : 2020/4/30 9:45
# @Author :
import json
from fastapi import FastAPI
from pydantic import BaseModel
from starlette.requests import Request
from starlette

本文探讨了从Flask切换至FastAPI框架解决接口高并发问题时遇到的Therewasanerrorparsingthebody错误。通过两种方法进行解决:一是修改原接口以适应FastAPI的数据读取方式;二是直接使用请求处理。文章详细介绍了具体实现步骤及如何运行FastAPI应用。
最低0.47元/天 解锁文章
3565

被折叠的 条评论
为什么被折叠?



