Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,10 +7,15 @@ app = Flask(__name__)
|
|
| 7 |
logging.basicConfig(level=logging.INFO)
|
| 8 |
logger = logging.getLogger(__name__)
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
@app.route('/v1/games/votes', methods=['GET'])
|
| 11 |
def get_game_votes():
|
| 12 |
"""
|
| 13 |
-
|
|
|
|
| 14 |
universe_ids = request.args.get('universeIds', '')
|
| 15 |
|
| 16 |
if not universe_ids:
|
|
@@ -21,35 +26,23 @@ def get_game_votes():
|
|
| 21 |
except ValueError:
|
| 22 |
return jsonify({"data": []}), 400
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
except requests.exceptions.RequestException as e:
|
| 36 |
-
logger.error(f"errorI: {e}")
|
| 37 |
-
data = []
|
| 38 |
-
for universe_id in ids:
|
| 39 |
-
data.append({
|
| 40 |
-
"id": universe_id,
|
| 41 |
-
"upVotes": 0,
|
| 42 |
-
"downVotes": 0
|
| 43 |
-
})
|
| 44 |
-
return jsonify({"data": data})
|
| 45 |
|
| 46 |
-
|
| 47 |
-
logger.error(f"Unexpected error: {e}")
|
| 48 |
-
return jsonify({"error": "not working"}), 500
|
| 49 |
|
| 50 |
@app.route('/', methods=['GET'])
|
| 51 |
def health_check():
|
| 52 |
-
"""
|
| 53 |
return jsonify({
|
| 54 |
"status": "healthy",
|
| 55 |
"message": "hello",
|
|
|
|
| 7 |
logging.basicConfig(level=logging.INFO)
|
| 8 |
logger = logging.getLogger(__name__)
|
| 9 |
|
| 10 |
+
# Custom vote configuration - change these values as needed
|
| 11 |
+
CUSTOM_UPVOTES = 100
|
| 12 |
+
CUSTOM_DOWNVOTES = 0
|
| 13 |
+
|
| 14 |
@app.route('/v1/games/votes', methods=['GET'])
|
| 15 |
def get_game_votes():
|
| 16 |
"""
|
| 17 |
+
Returns custom vote data for the specified universe IDs
|
| 18 |
+
"""
|
| 19 |
universe_ids = request.args.get('universeIds', '')
|
| 20 |
|
| 21 |
if not universe_ids:
|
|
|
|
| 26 |
except ValueError:
|
| 27 |
return jsonify({"data": []}), 400
|
| 28 |
|
| 29 |
+
# Build custom response with configurable votes
|
| 30 |
+
data = []
|
| 31 |
+
for universe_id in ids:
|
| 32 |
+
data.append({
|
| 33 |
+
"id": universe_id,
|
| 34 |
+
"upVotes": CUSTOM_UPVOTES,
|
| 35 |
+
"downVotes": CUSTOM_DOWNVOTES
|
| 36 |
+
})
|
| 37 |
+
|
| 38 |
+
response_data = {"data": data}
|
| 39 |
+
logger.info(f"Returning custom vote data: {response_data}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
return jsonify(response_data), 200
|
|
|
|
|
|
|
| 42 |
|
| 43 |
@app.route('/', methods=['GET'])
|
| 44 |
def health_check():
|
| 45 |
+
"""Health check endpoint"""
|
| 46 |
return jsonify({
|
| 47 |
"status": "healthy",
|
| 48 |
"message": "hello",
|