Replace static string by [basic] templated html
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e13df12508
commit
539c29045c
3 changed files with 23 additions and 5 deletions
|
@ -3,6 +3,7 @@ FROM python:2-slim
|
||||||
RUN pip install flask
|
RUN pip install flask
|
||||||
COPY /quake3_status.py /quake3_status.py
|
COPY /quake3_status.py /quake3_status.py
|
||||||
COPY /pyquake3.py /pyquake3.py
|
COPY /pyquake3.py /pyquake3.py
|
||||||
|
COPY /templates /templates
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
CMD ["python", "/quake3_status.py"]
|
CMD ["python", "/quake3_status.py"]
|
||||||
|
|
|
@ -21,11 +21,16 @@ def index(hours=None, minutes=None):
|
||||||
q = PyQuake3(q3server, rcon_password)
|
q = PyQuake3(q3server, rcon_password)
|
||||||
q.update()
|
q.update()
|
||||||
|
|
||||||
data = 'The name is %s, running map %s with %s human player(s) and %s bot(s).' % \
|
server_name = q.vars['sv_hostname']
|
||||||
(q.vars['sv_hostname'], \
|
current_map = q.vars['mapname']
|
||||||
q.vars['mapname'], \
|
human_players_count = len([x for x in q.players if not x.bot])
|
||||||
len([x for x in q.players if not x.bot]),\
|
bots_players_count = len([x for x in q.players if x.bot])
|
||||||
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
|
return data
|
||||||
|
|
||||||
|
|
12
templates/status.j2.html
Normal file
12
templates/status.j2.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>quake3-server-status</title>
|
||||||
|
<style>
|
||||||
|
font-family: Inconsolata, Courier New,Courier,Lucida Sans Typewriter,Lucida Typewriter,monospace;
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>The server {{ server_name }} is currently playaing map {{ current_map }} with {{ human_players_count }} human player(s) and {{ bots_players_count }} bot(s)</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue