diff --git a/Dockerfile b/Dockerfile index 013a737..e71a244 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM python:2-slim RUN pip install flask COPY /quake3_status.py /quake3_status.py COPY /pyquake3.py /pyquake3.py +COPY /templates /templates EXPOSE 5000 CMD ["python", "/quake3_status.py"] diff --git a/quake3_status.py b/quake3_status.py index a7de122..4592082 100644 --- a/quake3_status.py +++ b/quake3_status.py @@ -21,11 +21,16 @@ def index(hours=None, minutes=None): q = PyQuake3(q3server, rcon_password) q.update() - data = 'The name is %s, running map %s with %s human player(s) and %s bot(s).' % \ - (q.vars['sv_hostname'], \ - q.vars['mapname'], \ - len([x for x in q.players if not x.bot]),\ - len([x for x in q.players if x.bot])) + server_name = q.vars['sv_hostname'] + current_map = q.vars['mapname'] + human_players_count = len([x for x in q.players if not x.bot]) + bots_players_count = len([x for x in q.players if x.bot]) + + data = render_template('status.j2.html',\ + server_name=server_name,\ + current_map=current_map,\ + human_players_count=human_players_count,\ + bots_players_count=bots_players_count) return data diff --git a/templates/status.j2.html b/templates/status.j2.html new file mode 100644 index 0000000..4e9f583 --- /dev/null +++ b/templates/status.j2.html @@ -0,0 +1,12 @@ + + +
+The server {{ server_name }} is currently playaing map {{ current_map }} with {{ human_players_count }} human player(s) and {{ bots_players_count }} bot(s)
+ +