Skip to content

Instantly share code, notes, and snippets.

@mitchty
Created March 16, 2015 20:47
Show Gist options
  • Save mitchty/1c60c9f4e4df515eeb08 to your computer and use it in GitHub Desktop.
Save mitchty/1c60c9f4e4df515eeb08 to your computer and use it in GitHub Desktop.
flask uuid tracking per request
Per request uuid tracking in flask, or at least one way to go about it.
In create_app()
@app.before_request
def add_uuid_to_request_object():
request.uuid = uuid.uuid4()
Then in your route or MethodViews, I'm using MethodViews:
class SomeAPI(MethodView):
def get(self):
current_app.loggers.debug("%s etc..." % request.uuid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment