Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,15 +7,10 @@ app = Flask(__name__)
|
|
| 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 |
-
|
| 18 |
-
"""
|
| 19 |
universe_ids = request.args.get('universeIds', '')
|
| 20 |
|
| 21 |
if not universe_ids:
|
|
@@ -26,23 +21,35 @@ def get_game_votes():
|
|
| 26 |
except ValueError:
|
| 27 |
return jsonify({"data": []}), 400
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
})
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
@app.route('/', methods=['GET'])
|
| 44 |
def health_check():
|
| 45 |
-
"""
|
| 46 |
return jsonify({
|
| 47 |
"status": "healthy",
|
| 48 |
"message": "hello",
|
|
@@ -52,4 +59,4 @@ def health_check():
|
|
| 52 |
})
|
| 53 |
|
| 54 |
if __name__ == '__main__':
|
| 55 |
-
app.run(host='0.0.0.0', port=7860, debug=False)
|
|
|
|
| 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 |
+
miror """
|
|
|
|
| 14 |
universe_ids = request.args.get('universeIds', '')
|
| 15 |
|
| 16 |
if not universe_ids:
|
|
|
|
| 21 |
except ValueError:
|
| 22 |
return jsonify({"data": []}), 400
|
| 23 |
|
| 24 |
+
try:
|
| 25 |
+
roblox_url = f"https://games.roblox.com/v1/games/votes?universeIds={universe_ids}"
|
| 26 |
+
logger.info(f"test: {roblox_url}")
|
| 27 |
+
|
| 28 |
+
response = requests.get(roblox_url, timeout=10)
|
| 29 |
+
|
| 30 |
+
roblox_data = response.json()
|
| 31 |
+
logger.info(f"test: {roblox_data}")
|
| 32 |
+
|
| 33 |
+
return jsonify(roblox_data), response.status_code
|
| 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 |
+
except Exception as e:
|
| 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 |
+
"""checl"""
|
| 53 |
return jsonify({
|
| 54 |
"status": "healthy",
|
| 55 |
"message": "hello",
|
|
|
|
| 59 |
})
|
| 60 |
|
| 61 |
if __name__ == '__main__':
|
| 62 |
+
app.run(host='0.0.0.0', port=7860, debug=False)
|