Skip to content

Instantly share code, notes, and snippets.

@mitchty
Created March 16, 2015 20:47
Show Gist options
  • Select an option

  • Save mitchty/1c60c9f4e4df515eeb08 to your computer and use it in GitHub Desktop.

Select an option

Save mitchty/1c60c9f4e4df515eeb08 to your computer and use it in GitHub Desktop.

Revisions

  1. mitchty created this gist Mar 16, 2015.
    15 changes: 15 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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)