How to make flask response to client asynchronously?

前端 未结 2 2337
借酒劲吻你
借酒劲吻你 2021-02-20 19:02

Flask is a single thread web server. But I want to make it won\'t block when handle some time consuming request.

For example:

from flask import Flask
imp         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-20 19:27

    I believe you are asking about something called "streaming". For Flask this can be accomplished using generator functions and the yield keyword.

    Streaming is covered in more detail in the official Flask documentation, have a look here.

提交回复
热议问题