I have written code for fastapi and my API takes input base64 gif string and I'm getting this error basically the problem is when I have passed a big string then I'm getting this error but when I have passed the small or average size string then API runs successfully and give me a response. Anybody knows how to fix this error.
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
import base64
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials= True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/myapp",response_class=FileResponse)
async def detection(gif_url: str,img_url: str):
gif_data = base64.b64decode(gif_url)
gif_data_file = open("source.gif", "wb")
gif_data_file.write(gif_data)
return {"message":"Gif saved"}
gif_url receive base64 gif string.