Files
allwatch/modules/testmodule/module.py
T

30 lines
815 B
Python

from typing import override
from flask import Blueprint, render_template, jsonify, app
from base.basemodule import BaseModule
class TestModule(BaseModule):
def __init__(self, app: app):
name = "testmodule"
faIcon = "fa-vial"
blueprint = Blueprint(
"testmodule", __name__,
template_folder="templates",
static_folder="static"
)
blueprint.add_url_rule("/api/data", view_func=self.status_api)
super().__init__(app=app, name=name, faIcon=faIcon, blueprint=blueprint)
def status_api(self):
return jsonify({"status": "ok", "value": 42})
@override
def get_page(self):
return render_template("_page.html")
@override
def sync(self):
print("syncing")
MODULE_CLASS = TestModule