Skip to main content

A Django package for automatic HTTP/3 support

Project description

django-http3-package

Django HTTP/3 Package Documentation

Table of Contents

  1. Introduction
  2. Requirements
  3. Installation
  4. Configuration
  5. Usage
  6. Examples
  7. Troubleshooting
  8. Contributing
  9. License

Introduction

Django HTTP/3 is a package that enables automatic HTTP/3 support for Django projects. It simplifies the process of adding HTTP/3 capabilities to your Django application, allowing for improved performance and reduced latency for compatible clients.

Requirements

  • Python 3.8+
  • Django 3.0+
  • OpenSSL (for certificate generation)

Installation

To install the Django HTTP/3 package, run the following command:

pip install django-http3

Configuration

  1. Add 'django_http3' to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
    ...
    'django_http3',
]
  1. Add the HTTP/3 middleware to your MIDDLEWARE in settings.py:
MIDDLEWARE = [
    'django_http3.middleware.HTTP3Middleware',
    ...
]
  1. Update your asgi.py file to use the HTTP/3 ASGI application:
from django_http3.utils.asgi_utils import get_http3_asgi_application

application = get_http3_asgi_application()
  1. (Optional) Configure HTTP/3 settings in your settings.py:
HTTP3_HOST = 'localhost'  # Default
HTTP3_PORT = 8000  # Default

Usage

To run your Django server with HTTP/3 support, use the following management command:

python manage.py runhttp3

This command will start the server and automatically generate self-signed SSL certificates if they don't exist.

Examples

Basic Usage

Here's a simple example of how to set up a Django project with HTTP/3 support:

  1. Create a new Django project:
django-admin startproject myproject
cd myproject
  1. Install django-http3:
pip install django-http3
  1. Update settings.py:
INSTALLED_APPS = [
    ...
    'django_http3',
]

MIDDLEWARE = [
    'django_http3.middleware.HTTP3Middleware',
    ...
]
  1. Update asgi.py:
from django_http3.utils.asgi_utils import get_http3_asgi_application

application = get_http3_asgi_application()
  1. Run the server:
python manage.py runhttp3

Custom Port

To run the HTTP/3 server on a custom port:

  1. Update settings.py:
HTTP3_PORT = 8443
  1. Run the server:
python manage.py runhttp3

Production Setup

For production, you should use proper SSL certificates. Update your settings.py:

HTTP3_CERT_FILE = '/path/to/your/certfile.pem'
HTTP3_KEY_FILE = '/path/to/your/keyfile.pem'

Troubleshooting

  1. SSL Certificate Issues: If you encounter SSL certificate problems, ensure that you have OpenSSL installed and that the certificate files are readable by the application.

  2. Port Already in Use: If the port is already in use, you can change it in your settings.py file or stop the process using that port.

  3. Compatibility: Ensure your client supports HTTP/3. Not all browsers have HTTP/3 enabled by default.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

django-http3-0.2.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

django_http3-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file django-http3-0.2.0.tar.gz.

File metadata

  • Download URL: django-http3-0.2.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.8

File hashes

Hashes for django-http3-0.2.0.tar.gz
Algorithm Hash digest
SHA256 52c678174b79ebd48095d9c24969e514415a367fd7ce860748ef7b26ec38a7b9
MD5 f11215086f932d6036e03372bbae32c3
BLAKE2b-256 0251012ecd359ee4b52addaa8b3876ce7e2a74ea06aabebc64a311d85ad7071b

See more details on using hashes here.

File details

Details for the file django_http3-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: django_http3-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.8

File hashes

Hashes for django_http3-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 895742f8e8c6ea4482ee56589959ef8d04bdaa4bc58777178a6bd97f54a1009e
MD5 3ea5fb393701a674c925851cc0e6b33d
BLAKE2b-256 324f89ff4b2fbe2d1f1f6f9954ed9ebab2873a6a21079534a75e50fb0a154813

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