Metadata-Version: 2.4
Name: pyweboverlay
Version: 1.0.5
Summary: A Python package for creating simple local web overlays for streams and other needs
Author: chrisrca
License: Copyright 2025 chrisrca
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Repository, https://github.com/chrisrca/pyweboverlay
Keywords: overlay,web,obs
Classifier: Programming Language :: Python :: 3.9
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: ==3.9.*
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Flask==3.1.2
Requires-Dist: flask-socketio==5.3.6
Requires-Dist: requests==2.32.5
Dynamic: license-file

# pyweboverlay

A Python package for easily creating web overlays in Python using Flask and SocketIO.

## Installation

```bash
pip install pyweboverlay
```

## Usage

Set up your directory structure like the example provided in the repository:

```
│   example.py
│
└───rloverlay
    │   rloverlay.html
    │
    └───static
            background.png
            pivot.png
```

See `example.py` and the `rloverlay/` directory for a complete working example.

<img width="584" height="124" alt="image" src="https://github.com/user-attachments/assets/a81631ee-38f7-4795-8a9e-4d5131adce98" />

## API Reference

### `pyweboverlay.init(port=5000, verbose=True)`

Initialize the pyweboverlay server.

- **port** (int): Port number for the web server (default: 5000)
- **verbose** (bool): Enable detailed logging (default: True)

### `pyweboverlay.register(overlay, name, template_file=None, static_dir=None)`

Register an overlay instance with the server.

- **overlay** (Overlay): Instance of a class extending Overlay
- **name** (str): Unique name for the overlay's namespace
- **template_file** (str, optional): Path to custom HTML template file
- **static_dir** (str, optional): Path to directory for serving static files

Returns the overlay ID.

### `pyweboverlay.update(name, data=None)`

Update an overlay with new data and emit to connected clients.

- **name** (str): The registered name of the overlay
- **data** (any): Data to pass to the overlay's update method

### Creating Custom Overlays

Extend the `Overlay` base class and implement two required methods:

```python
from pyweboverlay import Overlay

class CustomOverlay(Overlay):
    def get_data(self):
        """Return current overlay data as a dictionary."""
        return {"key": "value"}
    
    def update(self, data=None):
        """Update the overlay state with new data."""
        if data is not None:
            # Process and store the data
            pass
```

## Features

- Real-time updates using WebSocket connections
- Custom HTML templates with Jinja2 templating
- Static file serving for images, CSS, and JavaScript
- Multiple overlays on a single server
- Minimal configuration required

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/chrisrca/pyweboverlay/blob/main/LICENSE) file for details.

## Contributing

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