Skip to main content

Beautiful debugging page for Starlette apps.

Project description

Starception

Beautiful debugging page for Starlette apps implemented as ASGI middleware.

PyPI GitHub Workflow Status GitHub Libraries.io dependency status for latest release PyPI - Downloads GitHub Release Date Lines of code

Installation

Install starception using PIP or poetry:

pip install starception
# or
poetry add starception

Add it as the first middleware in to your app:

app = Starlette(
    middleware=[
        Middleware(StarceptionMiddleware, debug=True),
        # other middleware here
    ],
)

Note, the middleware won't handle anything if debug=False, instead it will display plain string "Internal Server Error". Also, I would recommend to add it only for local development, as such error page, when enabled on prod by mistake, can expose sensitive data.

Usage with FastAPI

As this is pure ASGI middleware, you can use it with FastAPI. However, you cannot use app.middleware decorator and add it via app.add_middleware instead.

app = FastAPI()

app.add_middleware(StarceptionMiddleware, debug=True)

See FastAPI docs on middleware.

Screenshot

image

Features

  • secrets masking
  • solution hints
  • code snippets
  • display request info: query, body, headers, cookies
  • session contents
  • request and app state
  • platform information
  • environment variables

The middleware will automatically mask any value which key contains key, secret, token, password.

Quick start

See example application in examples/ directory of this repository.

Solution hints

If exception class has solution attribute then its content will be used as a solution hint.

class WithHintError(Exception):
    solution = (
        'The connection to the database cannot be established. '
        'Either the database server is down or connection credentials are invalid.'
    )

image

Credentials

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

starception-0.1.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

starception-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: starception-0.1.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.6 Linux/5.15.0-1014-azure

File hashes

Hashes for starception-0.1.1.tar.gz
Algorithm Hash digest
SHA256 516b8b36703a63e6ab017a35e2f6785747c5c1534cc6f5e6187ef0deffbf3ae2
MD5 393b0a71d84f91ba100e29585f465c0b
BLAKE2b-256 0e90d1f94216cf35ee7bec43aa2b8418ed4fc19415a344e46b03dc257b964365

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starception-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.6 Linux/5.15.0-1014-azure

File hashes

Hashes for starception-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eaade76d343ee7977ae59c65e7cdfb9d4d63be90a19cdf95328e865f22659fd2
MD5 95313fa617107d9d6ca96da22980c30b
BLAKE2b-256 1e668a3b4674cc265165bb0fb3e2dd7ebc2b27f6970bb68d071351280a36efce

See more details on using hashes here.

Supported by

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