从FastAPI的fileResponse读取响应?

2024-10-03 21:31:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要处理来自fileResponse的响应,并在inturn中添加一些其他数据,我需要在fileResponse中再次返回它

下面的代码显示了发送fileResponse的函数

def callAlgo():
    jsonFile_sample = "path to json file"
    return FileResponse(jsonFile_sample, media_type=content_type)

所以我需要在调用函数时收集这个响应,并对其进行一些操作

def loadFile():
    result = callAlgo()
    account_id = "XXXXXXXXXXXXXXXX"
    ******* need to open the file add some generated account id after this download the file 
     & then send this back as the file response ************

    return FileResponse

请告诉我怎么做?我对python非常陌生


Tags: thetosampleidreturndeftypeaccount