38 lines
910 B
Python
38 lines
910 B
Python
#!/usr/bin/env python3.6
|
|
# -*- coding:utf-8 -*-
|
|
""" basic q3 status page for my home server """
|
|
|
|
from flask import Flask
|
|
from flask import render_template
|
|
from pyquake3 import PyQuake3
|
|
import os
|
|
|
|
# pylint: disable=invalid-name
|
|
app = Flask(__name__)
|
|
app.url_map.strict_slashes = False
|
|
|
|
@app.route('/')
|
|
def index(hours=None, minutes=None):
|
|
""" main and only app """
|
|
|
|
q3server = os.environ.get("Q3_SERVER")
|
|
rcon_password = os.environ.get("RCONN_PASSWORD")
|
|
|
|
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]))
|
|
|
|
return data
|
|
|
|
def main():
|
|
""" main func """
|
|
app.run(host='::')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|