Toolkit for building web applications
Project description
ADC WebKit
A comprehensive toolkit for building modern web applications with Python. ADC WebKit provides a robust foundation for creating scalable web services with built-in HTTP extensions, authentication, body parsing, and OpenAPI support.
Features
- HTTP Extensions: Enhanced HTTP functionality with custom error handling
- Web Framework: Complete web application framework with routing and middleware support
- Authentication: Built-in JWT and base authentication systems
- Body Parsers: Support for JSON, form data, and streaming request bodies
- OpenAPI Integration: Automatic API documentation generation
- Type Safety: Full type hints and Pydantic model integration
- CRUD Operations: Pre-built CRUD endpoint patterns
- Response Handling: Flexible response formatting and streaming
Installation
pip install adc-webkit
Or install from source:
git clone https://github.com/ascet-dev/adc-webkit.git
cd adc-webkit
pip install -e .
Quick Start
from adc_webkit.web import WebApplication
from adc_webkit.web.endpoints import JSONEndpoint
from adc_webkit.web.auth import JWTAuth
# Create application
app = WebApplication()
# Define endpoint
class HelloEndpoint(JSONEndpoint):
async def get(self):
return {"message": "Hello, World!"}
# Add endpoint to app
app.add_endpoint("/hello", HelloEndpoint)
# Run application
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
Project Structure
adc_webkit/
├── __init__.py
├── errors.py # Custom HTTP error handling
├── types/ # Type definitions and models
│ ├── __init__.py
│ ├── base_model.py # Base Pydantic models
│ ├── base_search.py # Search functionality types
│ ├── count.py # Count response types
│ ├── file.py # File handling types
│ ├── http.py # HTTP-specific types
│ └── pagination.py # Pagination types
└── web/ # Web framework components
├── __init__.py
├── web.py # Main web application
├── auth/ # Authentication modules
│ ├── __init__.py
│ ├── base.py # Base authentication
│ └── jwt.py # JWT authentication
├── body_parsers/ # Request body parsers
│ ├── __init__.py
│ ├── base.py # Base parser interface
│ ├── factory.py # Parser factory
│ ├── form_data.py # Form data parser
│ ├── json.py # JSON parser
│ └── stream.py # Streaming parser
├── endpoints/ # Endpoint implementations
│ ├── __init__.py
│ ├── base.py # Base endpoint class
│ ├── crud.py # CRUD operations
│ ├── json.py # JSON endpoints
│ ├── request_context.py # Request context
│ ├── response.py # Response handling
│ └── stream.py # Streaming endpoints
└── openapi/ # OpenAPI documentation
├── __init__.py
├── auth.py # Auth schema generation
├── endpoint.py # Endpoint schema
└── schema.py # Schema utilities
Core Components
HTTP Extensions (adc_webkit)
The main package providing enhanced HTTP functionality:
- Custom error handling with detailed error responses
- Type-safe request/response models
- Pagination support
- File upload/download handling
Web Framework (adc_webkit.web)
A complete web application framework built on top of aiohttp:
- WebApplication: Main application class with routing and middleware
- Endpoints: Pre-built endpoint patterns for common use cases
- Authentication: JWT and base authentication systems
- Body Parsers: Flexible request body parsing
- OpenAPI: Automatic API documentation generation
Type System (adc_webkit.types)
Comprehensive type definitions using Pydantic:
- Base models for consistent data structures
- Search and pagination types
- HTTP-specific type definitions
- File handling types
Usage Examples
CRUD Operations
from adc_webkit.web.endpoints import CRUDEndpoint
class ProductEndpoint(CRUDEndpoint):
async def list(self):
return {"products": []}
async def create(self):
data = await self.get_json()
return {"created": data}
async def retrieve(self, id: str):
return {"product": {"id": id}}
async def update(self, id: str):
data = await self.get_json()
return {"updated": {"id": id, **data}}
async def delete(self, id: str):
return {"deleted": id}
app.add_endpoint("/products", ProductEndpoint)
Authentication
from adc_webkit.web.auth import JWTAuth
class ProtectedEndpoint(JSONEndpoint):
auth_class = JWTAuth
async def get(self):
user = self.request.user
return {"message": f"Hello, {user.username}!"}
Custom Body Parser
from adc_webkit.web.body_parsers import BaseBodyParser
class CustomParser(BaseBodyParser):
async def parse(self, request):
# Custom parsing logic
return await request.text()
class CustomEndpoint(JSONEndpoint):
body_parser_class = CustomParser
Configuration
ADC WebKit supports various configuration options:
app = WebApplication(
title="My API",
version="1.0.0",
description="My awesome API",
debug=True
)
Development
Running Tests
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Issues: GitHub Issues
- Documentation: ToBe
Requirements
- Python 3.8+
- python-jose[cryptography]>=3.5.0
- pydantic>=2.11.7
- starlette>=0.47.0
- ujson>=5.10.0
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 adc_webkit-0.1.0.tar.gz.
File metadata
- Download URL: adc_webkit-0.1.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c94e86980fc9f69f85c03bcfac8889d9fd2556e85ea5fb2aab3201d0925c7cd5
|
|
| MD5 |
40c045444e2cb61579b69fefb1a55b94
|
|
| BLAKE2b-256 |
50d366fff3dea3c9edf28173f0a4fcee6a3f6b2ce041df3384e7ac310ff70c68
|
File details
Details for the file adc_webkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: adc_webkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abc3e6148f277fdaf8e64a600b23d4a5c2742f01d23767558903ebabebaa02e4
|
|
| MD5 |
ab1bef379a2d24b16489b5633696ed44
|
|
| BLAKE2b-256 |
b219635bd0ba462b0c77e5de0523d4506726bcae8e803c184b038216a782d593
|