1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 16:16:58 -05:00
fHDHR_NextPVR/origin/origin_web/origin_html.py
2020-12-10 09:41:45 -05:00

31 lines
1.1 KiB
Python

from flask import request, render_template_string
import pathlib
from io import StringIO
class Origin_HTML():
endpoints = ["/origin", "/origin.html"]
endpoint_name = "page_origin_html"
def __init__(self, fhdhr):
self.fhdhr = fhdhr
self.template_file = pathlib.Path(self.fhdhr.config.internal["paths"]["origin_web"]).joinpath('origin.html')
self.template = StringIO()
self.template.write(open(self.template_file).read())
def __call__(self, *args):
return self.get(*args)
def get(self, *args):
if self.fhdhr.originwrapper.setup_success:
origin_status_dict = {
"Setup": "Success",
"Address": self.fhdhr.originwrapper.originservice.nextpvr_address,
"Total Channels": len(self.fhdhr.device.channels.list)
}
else:
origin_status_dict = {"Setup": "Failed"}
return render_template_string(self.template.getvalue(), request=request, fhdhr=self.fhdhr, origin_status_dict=origin_status_dict, list=list)