request-id-flask
Attach a unique identifier to every HTTP request in your WSGI or ASGI application.
request-id-flask is implemented as a WSGI and ASGI middleware.
The package will do one of two things:
-
Read the
X-Request-IDHTTP header from a client HTTP request and return the sameX-Request-IDHTTP header in the server HTTP response and is stored in the WSGIenviron. -
Or, when no
X-Request-IDHTTP header is present in the client HTTP request, generate a new and uniquerequest_ididentifier (using uuid 4) which is stored in the WSGIenvironand set as theX-Request-IDHTTP header in the server HTTP responser.
Requirements
- Python 3.6 or above
Installation
You can install the request-id-flask package using pip:
pip install request-id-flask
However, recommended to add it to the requirements.txt file instead, and install using: pip install -r requirements.txt
request-id-flask
Access the request_id
The REQUEST_ID is stored in the request environ dictionary and may be accessed from anywhere this is available in Flask.
Changelog
- Version 0.0.4 adds support for Quart.
- Version 0.0.3 adds support for the app factory pattern.
Flask Usage
from flask import (
Flask,
request
)
from request_id import RequestId
app = Flask(__name__)
RequestId(app)
@app.route('/')
def index():
request_id = request.environ.get('REQUEST_ID', '')
return str(request_id)
Quart Usage
from quart import (
Quart,
request
)
from request_id import RequestId
app = Quart(__name__)
RequestId(app)
@app.route('/')
async def index():
request_id = request.environ.get('REQUEST_ID', '')
return await str(request_id)
Metadata
Release files for request-id-flask 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| request-id-flask-0.0.4.tar.gz | 4.4 kB | Without provenance | Details for request-id-flask-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| request_id_flask-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for request_id_flask-0.0.4-py3-none-any.whl |
Total release size: 8.5 kB
Release files / request-id-flask-0.0.4.tar.gz
| Download URL | request-id-flask-0.0.4.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
302fadf7dafdede17994f9f0e5cb7e0f0391306194a7d646bc09e6885d634729
|
|
BLAKE2b-256 checksum How to use checksums |
6cbc78c87c5f16b9c23affc7c5de8097bc6e7e7d53d05ff21fef5e3e35fc79f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|
Release files / request_id_flask-0.0.4-py3-none-any.whl
| Download URL | request_id_flask-0.0.4-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49a6dc1e3fd93f3d0ce61f1983640d4635bb038818f2341366087c8094424885
|
|
BLAKE2b-256 checksum How to use checksums |
75f44c51c2f7fc9d3cb56ce6a353523b9d0722ec64f90b022c210a9487019091
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|
Security for request-id-flask 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.