fix path to html

This commit is contained in:
Roy Olav Purser 2021-05-09 18:49:40 +02:00
parent 870e655038
commit 82029e2537
Signed by: roypur
GPG Key ID: E14D26A036F21656
2 changed files with 16 additions and 9 deletions

View File

@ -3,6 +3,7 @@ RUN ["apk", "add", "--no-cache", "--repository", "https://dl-cdn.alpinelinux.org
RUN ["mkdir", "/app"] RUN ["mkdir", "/app"]
COPY ["stream.py", "/app/stream.py"] COPY ["stream.py", "/app/stream.py"]
COPY ["sources.py", "/app/sources.py"] COPY ["sources.py", "/app/sources.py"]
COPY ["index.html", "/app/index.html"]
RUN ["chmod", "-R", "755", "/app"] RUN ["chmod", "-R", "755", "/app"]
COPY ["tv.json", "/app/tv.json"] COPY ["tv.json", "/app/tv.json"]
RUN ["python3", "/app/sources.py"] RUN ["python3", "/app/sources.py"]

View File

@ -50,9 +50,11 @@ if icecast_server is not None and stream_server is not None:
playlist += stream_server + key + "\n" playlist += stream_server + key + "\n"
template = None template = None
with open("index.html", "r") as f: try:
template = tornado.template.Template(f.read().strip()) with open("/app/index.html", "r") as f:
template = tornado.template.Template(f.read().strip())
except Exception as e:
print(e)
def get_proxy_url(proxy, current, path): def get_proxy_url(proxy, current, path):
data = {} data = {}
@ -106,12 +108,16 @@ class MainHandler(tornado.web.RequestHandler):
else: else:
self.set_status(404) self.set_status(404)
if write: if write:
self.write("stream not found") self.write("Stream not found.")
def handle_render(self, provider, write): def handle_render(self, provider, write):
stream_path = f'{self.request.path}?provider={provider}' if template is not None:
rendered = template.generate(stream=stream_path) stream_path = f'{self.request.path}?provider={provider}'
self.write(rendered) rendered = template.generate(stream=stream_path)
self.write(rendered)
else:
self.set_status(404)
self.write("HTML template missing.")
def handle_stream(self, provider, write): def handle_stream(self, provider, write):
upstream = None upstream = None
@ -139,7 +145,7 @@ class MainHandler(tornado.web.RequestHandler):
if upstream is None: if upstream is None:
self.set_status(404) self.set_status(404)
if write: if write:
self.write("stream not found") self.write("Stream not found.")
else: else:
data = rewrite(upstream, provider) data = rewrite(upstream, provider)
if data is None: if data is None: