在单个请求中将多个JSON记录一起批处理

时间:2019-10-01 22:44:37

标签: flask flask-restful

在我的flask API中,我想在一个请求中将多个JSON记录一起批处理,然后将其发布到其他API。我在考虑以下伪代码。有没有办法保持烧瓶中的状态,正确的方法是什么?

@app.route(URL, methods=['GET', 'POST'])
def handle():
    while True:
        if request.is_json:
            req_data = request.get_json()
            batch.append(req_data)
            if len(batch) > WINDOW: 
                response = api.post_data(log_type, batch)
                return "{}".format(response.status_code) 

0 个答案:

没有答案