q3_server_status/quake3_status.py

37 lines
818 B
Python
Raw Normal View History

2020-03-25 01:37:41 +01:00
#!/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 of %s is %s, running map %s with %s player(s).' % \
(q.get_address(), q.vars['sv_hostname'], \
q.vars['mapname'], len(q.players))
return data
def main():
""" main func """
app.run(host='::')
if __name__ == '__main__':
main()