FlowSurgeon — framework-agnostic profiling middleware for Python (WSGI & ASGI).
Project description
FlowSurgeon
Framework-agnostic profiling middleware for Python — works with Flask (WSGI) and FastAPI / Starlette (ASGI) out of the box.
FlowSurgeon injects a lightweight debug panel into every HTML response and stores request history in a local SQLite database, giving you timing, headers, and status codes without touching your application code.
Features
- Zero required dependencies — pure stdlib
- WSGI middleware (
FlowSurgeonWSGI) for Flask, Django, and any WSGI app - ASGI middleware (
FlowSurgeonASGI) for FastAPI, Starlette, and any ASGI app FlowSurgeon()factory — auto-detects WSGI vs ASGI- Inline debug panel injected into HTML responses
- Built-in history UI at
/__flowsurgeon__/ - SQLite persistence with auto-pruning
- Sensitive header redaction (
Authorization,Cookie) FLOWSURGEON_ENABLEDenvironment variable kill switch
Installation
pip install flowsurgeon
Quick start
FastAPI (ASGI)
from fastapi import FastAPI
from flowsurgeon import FlowSurgeon, Config
_app = FastAPI()
app = FlowSurgeon(_app, config=Config(enabled=True))
@_app.get("/")
async def index():
return {"hello": "world"}
Run with uvicorn:
uvicorn myapp:app
Flask (WSGI)
from flask import Flask
from flowsurgeon import FlowSurgeon, Config
flask_app = Flask(__name__)
flask_app.wsgi_app = FlowSurgeon(
flask_app.wsgi_app,
config=Config(enabled=True),
)
Configuration
from flowsurgeon import Config
Config(
enabled=True, # default: False (or FLOWSURGEON_ENABLED=1)
allowed_hosts=["127.0.0.1", "::1"], # hosts that see the panel
db_path="flowsurgeon.db", # SQLite file path
max_stored_requests=1000, # auto-prune threshold
debug_route="/__flowsurgeon__", # history UI prefix
strip_sensitive_headers=["authorization", "cookie", "set-cookie"],
)
Debug UI
| Route | Description |
|---|---|
/__flowsurgeon__/ |
Paginated request history |
/__flowsurgeon__/{id} |
Full detail for one request |
Roadmap
- v0.3.0 — SQL query tracking (SQLAlchemy, DB-API 2.0)
- v0.4.0 — CPU and memory profiling panel
- v0.5.0 — Log capture and headers panel
- v0.6.0 — Improved history/search UI
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flowsurgeon-0.2.0.tar.gz.
File metadata
- Download URL: flowsurgeon-0.2.0.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7245fb9e0682b195898ac6721729ab484b1787bfdba6fd690681b33b96f641b9
|
|
| MD5 |
78327247f70cfa26ee9a001fd4557a2c
|
|
| BLAKE2b-256 |
79cad31ce8cd25c7a9f0cec69261a39b2ac7f2ca5f862297e69d08a7e32dac9b
|
File details
Details for the file flowsurgeon-0.2.0-py3-none-any.whl.
File metadata
- Download URL: flowsurgeon-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1064b1ad5974bc354cb9bf79a0ab49913a3b8688cd3a51bea039f84296d43ce5
|
|
| MD5 |
55bdf77f8f9c0e219bc0a93562fa17d0
|
|
| BLAKE2b-256 |
3f267487bb11efd466d23cd13fc055860542f7e720050967ced339da198152ca
|