Skip to content

chrisrca/pyweboverlay

Repository files navigation

pyweboverlay

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

Installation

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.

image

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:

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 file for details.

Contributing

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published