Skip to main content

WhoWhyWhen middleware for FastAPI

Project description

fastapi-whowhywhen

WhoWhyWhen middleware for FastAPI. Create a WhoWhyWhen account at https://whowhywhen.com/ and get your API key.

Installation

pip install fastapi-whowhywhen

Usage

from fastapi import FastAPI
from fastapi_whowhywhen import WhoWhyWhenMiddleware
from starlette.background import BackgroundTasks

app = FastAPI()

app.add_middleware(
    WhoWhyWhenMiddleware,
    api_key="YOUR_API_KEY"
)

@app.get("/")
async def root():
    return {"message": "Hello, World!"}

# Add the following middleware to your FastAPI app
@app.middleware("http")
async def add_background_tasks(request: Request, call_next):
    request.state.background_tasks = BackgroundTasks()
    response = await call_next(request)
    response.background = request.state.background_tasks
    return response

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_whowhywhen-0.1.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_whowhywhen-0.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_whowhywhen-0.1.1.tar.gz.

File metadata

  • Download URL: fastapi_whowhywhen-0.1.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.4

File hashes

Hashes for fastapi_whowhywhen-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ec534761ffc1a94d828630bf4c34e5fe6e5201ebfe3184a2c29616b28a2692f
MD5 534b36286e3294ea08ed80e6f4726537
BLAKE2b-256 9526cf06bfbc4af9806b5246cd3449b499337b3daeb91637920d86b26eb09562

See more details on using hashes here.

File details

Details for the file fastapi_whowhywhen-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_whowhywhen-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb243e941b7d9fd995564a433a3b10504de1f8c295fa0cd17f45129d688c5018
MD5 9059c953d1059658029e08c83a4b8789
BLAKE2b-256 8e849639f9bb91beb5c869c154d79ecded8eff460c72c7f03531cdc8f2485c3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page