简体   繁体   English

如何在 fastapi 中处理大量 json 数据响应负载?

[英]How to handle large amount of json data response payload in fastapi?

a get call which has many lines of json respone gets some time to respond in swagger ui.具有多行 json 响应的 get 调用有一些时间在 swagger ui 中响应。

how can reduce this time;如何减少这个时间; but, i want each response attrebute from my big responds model..但是,我希望每个响应属性都来自我的大响应 model ..

i have tried gzip content encoading.我尝试过gzip内容编码。 but, it does not solved my problem;但是,它并没有解决我的问题; because of the large number of line response;因为大量的线路响应;

for eg: while getting all job details (note:one job responds 36000 line response)例如:在获取所有工作详细信息时(注意:一个工作响应 36000 行响应)

I'm a beginner我是初学者

You don't have an issue with FastAPI. FastAPI 没有问题。 Your question is how to handle a large response body with Swagger UI.您的问题是如何使用 Swagger UI 处理大型响应体。

a get call which has many lines of json respone gets some time to respond in swagger ui. 具有多行 json 响应的 get 调用有一些时间在 swagger ui 中响应。

This is a known issue with Swagger UI, even sometimes large response bodies cause hanging( see ).这是 Swagger UI 的一个已知问题,甚至有时大型响应体也会导致挂起(请参阅)。

how can reduce this time 怎么能减少这个时间

In your case using some tool like Postman or Insomnia could fix this.在您的情况下,使用Postman 或 Insomnia等工具可以解决此问题。

i have tried gzip content encoading. 我尝试过 gzip 内容编码。 but, it does not solved my problem; 但是,它并没有解决我的问题; because of the large number of line response; 因为大量的线路响应;

Expected.预期的。 This will not make any effect in Swagger, yes it can reduce the latency when you are dealing with large response bodies.这不会在 Swagger 中产生任何影响,是的,当您处理大型响应体时,它可以减少延迟。 But in the end, Swagger is going to show it as JSON.但最后,Swagger 将显示为 JSON。 So this will not make any changes to your Swagger experience.因此,这不会对您的 Swagger 体验产生任何影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM