A Django package for automatic HTTP/3 support
Project description
django-http3-package
Django HTTP/3 Package Documentation
Table of Contents
- Introduction
- Requirements
- Installation
- Configuration
- Usage
- Examples
- Troubleshooting
- Contributing
- 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
- Add 'django_http3' to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
...
'django_http3',
]
- Add the HTTP/3 middleware to your MIDDLEWARE in settings.py:
MIDDLEWARE = [
'django_http3.middleware.HTTP3Middleware',
...
]
- 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()
- (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:
- Create a new Django project:
django-admin startproject myproject
cd myproject
- Install django-http3:
pip install django-http3
- Update settings.py:
INSTALLED_APPS = [
...
'django_http3',
]
MIDDLEWARE = [
'django_http3.middleware.HTTP3Middleware',
...
]
- Update asgi.py:
from django_http3.utils.asgi_utils import get_http3_asgi_application
application = get_http3_asgi_application()
- Run the server:
python manage.py runhttp3
Custom Port
To run the HTTP/3 server on a custom port:
- Update settings.py:
HTTP3_PORT = 8443
- 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
-
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.
-
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.
-
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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52c678174b79ebd48095d9c24969e514415a367fd7ce860748ef7b26ec38a7b9
|
|
| MD5 |
f11215086f932d6036e03372bbae32c3
|
|
| BLAKE2b-256 |
0251012ecd359ee4b52addaa8b3876ce7e2a74ea06aabebc64a311d85ad7071b
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
895742f8e8c6ea4482ee56589959ef8d04bdaa4bc58777178a6bd97f54a1009e
|
|
| MD5 |
3ea5fb393701a674c925851cc0e6b33d
|
|
| BLAKE2b-256 |
324f89ff4b2fbe2d1f1f6f9954ed9ebab2873a6a21079534a75e50fb0a154813
|