code: def start_response_callback(start_response, origin):
          
          def callback(status, headers, exc_info=None):
              """Add our headers to response using a closure."""
              headers.append(('Access-Control-Allow-Origin', origin))
              # Call upstream start_response
              start_response(status, headers, exc_info)
          return callback
docs: Intercept upstream start_response and adds our headers.