Answers for "raise RuntimeError(_app_ctx_err_msg) RuntimeError: Working outside of application context."

C
0

raise RuntimeError(_request_ctx_err_msg) RuntimeError: Working outside of request context

@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"
Posted by: Guest on May-17-2020
0

working outside of application context

# when app is initialized using app_factory

@classmethod
def setUpClass(self):
    self.app = create_app("testing")
    self.client = self.app.test_client()
Posted by: Guest on August-25-2020

Code answers related to "raise RuntimeError(_app_ctx_err_msg) RuntimeError: Working outside of application context."

Code answers related to "C"

Browse Popular Code Answers by Language