Skip to content

Commit

Permalink
add endpoint for full query data
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Hooper committed May 11, 2015
1 parent 2151c6e commit 5f48996
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python

import os
import os,socket
from flask import Flask,jsonify
from mcstatus import MinecraftServer

Expand All @@ -12,6 +12,13 @@ def query_server(server):
return server.query()


@app.route("/<server>", methods=['GET'])
def server_main(server):
"""Get full response of minecraft query"""
query = query_server(server)
return jsonify(raw=query.raw,players=query.players.names)


@app.route("/<server>/players", methods=['GET'])
def players(server):
"""Query online players from server"""
Expand All @@ -21,5 +28,12 @@ def players(server):

if __name__ == '__main__':
port = int(os.environ.get('PORT', '5000'))

if os.environ.get('DEBUG', '0') == '1':
app.debug = True

timeout_secs = float(os.environ.get('TIMEOUT', '3'))
socket.setdefaulttimeout(timeout_secs)

app.run(host='0.0.0.0', port=port)

1 change: 1 addition & 0 deletions docker-compose.yml
Expand Up @@ -5,3 +5,4 @@ app:
- "5000:5000"
environment:
PORT: "5000"
DEBUG: "1"

0 comments on commit 5f48996

Please sign in to comment.