title: Return from before_request() in flask
body: <p>I'm new to flask and currently converting an existing WSGI application to run through flask as long term it'll make life easier.</p>
  
  <p>All requests are POST to specific routes however the current application inspects the post data prior to executing the route to see if the request needs to be run at all or not (i.e. if an identifier supplied in the post data already exists in our database or not).</p>
  
  <p>If it does exist a 200 code and json is returned "early" and no other action is taken; if not the application continues to route as normal.</p>
  
  <p>I think I can replicate the activity at the right point by calling before_request() but I'm not sure if returning a flask Response object from before_request() would terminate the request adequately at that point? Or if there's a better way of doing this? </p>
  
  <p>NB: I must return this as a 200 - other examples I've seen result in a redirect or 4xx error handling (as a close parallel to this activity is authentication) so ultimately I'm doing this at the end of before_request():</p>
  
  <pre><code>    if check_request_in_progress(post_data) is True:
          response = jsonify({'request_status': 'already_running'})
          response.status_code = 200
          return response
      else:
          add_to_requests_in_progress(post_data)
  </code></pre>
  
  <p>Should this work (return and prevent further routing)? </p>
  
  <p>If not how can I prevent further routing after calling before_request()?</p>
  
  <p>Is there a better way?</p>