📌  相关文章
📜  引发 RuntimeError(_request_ctx_err_msg) RuntimeError:在请求上下文之外工作 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:25.780000             🧑  作者: Mango

代码示例1
@app.route('/my_endpoint', methods=['POST'])
def my_endpoint_handler():
    #do tracking in sub-thread so we don't hold up the page
    def handle_sub_view(req):
        with app.test_request_context():
            from flask import request
            request = req
            # Do Expensive work
    thread.start_new_thread(handle_sub_view, (request))
    return "Thanks"