From 323bbe0161d14c206f27744f0ab46f03cc0e2db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gl=C3=BCpker?= Date: Fri, 23 Mar 2018 22:27:20 +0100 Subject: Introduce new page with serverinfo --- config/server.json.example | 12 ++++++++ main.py | 13 ++++++++ static/style.css | 71 +++++++++++++++++++++++++++++++++++++++++++ templates/lobby_html.jinja | 1 + templates/premades_html.jinja | 1 + templates/server_html.jinja | 61 +++++++++++++++++++++++++++++++++++++ 6 files changed, 159 insertions(+) create mode 100644 config/server.json.example create mode 100644 templates/server_html.jinja diff --git a/config/server.json.example b/config/server.json.example new file mode 100644 index 0000000..9fdc773 --- /dev/null +++ b/config/server.json.example @@ -0,0 +1,12 @@ +{ + "Servername #1": { + "ip": "127.0.0.1", + "port": 27015, + "gameid": 730 + }, + "Servername #2": { + "ip": "1.2.3.4", + "port": 1337, + "gameid": 730 + } +} diff --git a/main.py b/main.py index 7577d2d..9ae9b54 100755 --- a/main.py +++ b/main.py @@ -168,6 +168,19 @@ def premades(): connections=connections ) +@app.route("/server", methods=['GET']) +def server(): + with open(os.path.join(CONFIG, 'server.json'), 'rt') as config: + servers = json.load(config) + for name, server in servers.items(): + server['data'] = QueryServer.QueryServer(server['ip'], server['port'], server['gameid']) + return render_template('server_html.jinja', + servers=servers + # profiles=premadedata, + # display_time=display_time, + # connections=connections + ) + if __name__ == '__main__': # print(steam.getFriends("76561197963063991")) # print(steam.getFriends("76561197963882989")) diff --git a/static/style.css b/static/style.css index 454aedd..2601971 100644 --- a/static/style.css +++ b/static/style.css @@ -148,6 +148,77 @@ span.maininfo { font-size: x-small; } span.steamname { font-size: medium; /* font-family: serif; */ font-weight: bold; width: 110px; word-wrap: break-word; } img.gameimage { width: 95%; } +div.server { + display: inline-block; + width: 450px; + min-height: 500px; + text-align: center; + margin: 2px 5px 2px 5px; + padding: 0; + overflow: hidden; + /* border: 1px solid lightblue; */ +} + +div.serverheader { + display: inline-block; + vertical-align: top; + width: 448px; + height: 20px; + margin: 0; + padding-bottom: 5px; + overflow: hidden; + /* background-color: pink; */ + /* border: 1px solid pink; */ +} + +div.serverdata { + display: inline-block; + vertical-align: top; + width: 440px; + height: 478px; + margin: 0; + padding-bottom: 0; + overflow: hidden; + overflow-y: auto; + /* overflow: scroll; */ +} + +a.servername { + color: lightblue; + font-weight: bold; + /* text-decoration: underline; */ +} + +ul.server { + list-style-type: none; + margin: 0 10px 10px 10px; + padding: 0; + overflow: hidden; + /* background-color: #ff00ff; */ +} + +li.servermap { + float: left; + padding: 0 5px; +} + +li.playerinfo { + float: right; +} + +table.playerlist { + width: 100%; + margin: 0 20px 0 20px; +} + +td { + text-align: center; +} + +td.name { + text-align: left; +} + /***************************************/ /* Colors for different online states: */ /* offline online busy away snooze */ diff --git a/templates/lobby_html.jinja b/templates/lobby_html.jinja index a9598bc..3f4fed4 100644 --- a/templates/lobby_html.jinja +++ b/templates/lobby_html.jinja @@ -11,6 +11,7 @@ diff --git a/templates/premades_html.jinja b/templates/premades_html.jinja index 565ef21..d08da8f 100644 --- a/templates/premades_html.jinja +++ b/templates/premades_html.jinja @@ -9,6 +9,7 @@ diff --git a/templates/server_html.jinja b/templates/server_html.jinja new file mode 100644 index 0000000..3f918a8 --- /dev/null +++ b/templates/server_html.jinja @@ -0,0 +1,61 @@ + + + CS:GO Lobbylinkfinder + + + + + + + + + + {% for name, info in servers.items() %} +
+ + {% if info['data'] %} +
+ + + +
    +
  • {{ info['data']['map'] }}
  • +
  • {{ info['data']['players'] }} / {{ info['data']['playersmax'] }}
  • +
+ + {% if info['data']['players'] %} + + + + + + + {% for player in info['data']['player_info'] | sort(attribute='score', reverse=True) %} + + + + + + {% endfor %} +
NameScoreTime
{{ player['name'] }}{{ player['score'] }}{{ player['duration'] }}s
+ {% endif %} + +
+ + {% else %} + This server did not respond in time. + {% endif %} +
+ {% endfor %} + + + + +