Skip to content

Django app for creating endpoints that log incoming request and return mock data

License

Notifications You must be signed in to change notification settings

simonw/django-http-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-http-debug

PyPI Tests Changelog License

Django app for creating database-backed HTTP debug endpoints

Background on this project: django-http-debug, a new Django app mostly written by Claude

Installation

Install this library using pip:

pip install django-http-debug

Configuration

Once installed in the same environment as your Django application, add the following to INSTALLED_APPS in your Django settings:

INSTALLED_APPS = [
    # ...
    'django_http_debug',
    # ...
]

And add this to MIDDLEWARE:

MIDDLEWARE = [
    # ...
    "django_http_debug.middleware.DebugMiddleware",
    # ...
]

Then run ./manage.py migrate to create the necessary database tables.

Usage

You can configure new endpoints in the Django admin. These will only work if they are for URLs that are not yet being served by the rest of your application.

Give an endpoint a path (starting without a /) such as:

webhooks/debug/

You can optionally configure the returned body or HTTP headers here too.

If you want to return a binary body - a GIF for example - you can set that endpoint to use Base64 encoding and then paste a base64-encoded string into the body field.

On macOS you can create base64 strings like this:

base64 -i pixel.gif -o -

Any HTTP requests made to /webhooks/debug/ will be logged in the database. You can view these requests in the Django admin.

You can turn off the "Logging enabled" option on an endpoint to stop logging requests to it to the database.

Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

cd django-http-debug
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

About

Django app for creating endpoints that log incoming request and return mock data

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages