Metadata-Version: 2.1
Name: tezapi
Version: 0.0.2
Summary: Asynchronous web framework for building powerful web APIs and applications with Python
Author-email: dev-au <devaubusiness@gmail.com>
Project-URL: Homepage, https://github.com/dev-au/tezapi
Project-URL: Issues, https://github.com/dev-au/tezapi/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp~=3.9.5
Requires-Dist: jinja2~=3.1.4

Certainly! Here's the full README.md file incorporating all the detailed explanations and examples:

```markdown
# aiohttp-api

aiohttp-api is an asynchronous web framework for building powerful and efficient web APIs and applications with Python. It leverages the asyncio and aiohttp libraries to provide a seamless development experience for building high-performance web applications.

## Key Features

- Asynchronous by design: Built on top of asyncio and aiohttp, aiohttp-api allows you to write highly concurrent and efficient web applications.
- Simple and intuitive API: With minimal boilerplate and sensible defaults, aiohttp-api provides a clean and intuitive API for defining routes and handling requests.
- Error handling made easy: aiohttp-api simplifies error handling with support for both simple and class-based error responses, making it straightforward to handle exceptions and provide meaningful feedback to clients.
- Schema validation with SchemaModel: aiohttp-api makes form validation easy with the SchemaModel class, allowing you to validate incoming request data against defined schemas effortlessly.
- Template rendering with Jinja2Template: aiohttp-api includes built-in support for Jinja2Template, allowing you to render HTML templates seamlessly.

## Installation

You can install aiohttp-api via pip:


pip install tezapi
```

## Quick Start

```python
from tezapi import AioAPI, Request
from tezapi.exceptions import APIError, ClassBaseError
from tezapi.schemas import SchemaModel
from tezapi.templating import Jinja2Template

app = AioAPI()
render = Jinja2Template('templates')

# Define routes and handlers
@app.get("/")
async def hello():
    return "Hello, aiohttp-api!"

# Run the aiohttp-api application
app.run()
```

## Advanced Features and Best Practices

In addition to the basic setup and usage, aiohttp-api offers advanced features and best practices for building robust web applications.

### Advanced Routing Techniques

#### Route Parameters

In aiohttp-api, you can define routes with parameters that capture dynamic values from the URL. For example:

```python
@app.get("/users/{user_id}")
async def get_user(request: Request, user_id: int):
    # Retrieve user data based on user_id
    return {'user_id': user_id}
```

#### Query Parameters

You can also handle query parameters in aiohttp-api routes. For example:

```python
@app.get("/search")
async def search_users(request: Request):
    query = request.query.get('q')
    # Perform search based on query parameter
    return {'query': query}
```

### Middleware

Middleware in aiohttp-api allows you to intercept and modify requests and responses before they reach the handler. You can use middleware for tasks such as authentication, logging, and request/response manipulation.

```python
async def logger_middleware(request: Request, handler, **kwargs):
    # Log request information
    print(f"Received {request.method} request to {request.path}")
    
    # Call the next middleware/handler in the chain
    response = await handler(request, **kwargs)
    
    # Log response information
    print(f"Responded with {response.status}")
    
    return response

# Register middleware with the aiohttp-api app
app.add_middleware(logger_middleware)
```

### Static Files and Asset Handling

AioAPI allows you to serve static files such as CSS, JavaScript, and images alongside your dynamic content. You can use the `StaticFiles` class to define a route for serving static files from a directory:

```python
from tezapi.static import StaticFiles

# Define a route for serving static files
app.add_static('/static', path='static')
```

### Testing

Testing is an essential part of the development process. AioAPI provides utilities for testing your web applications, including the ability to simulate HTTP requests and responses.

```python
from tezapi.testing import AioAPITestClient

async with AioAPITestClient(app) as client:
    response = await client.get('/hello')
    assert response.status == 200
    assert await response.text() == 'Hello, aiohttp-api!'
```

