jerrrycans commited on
Commit
cffed60
·
verified ·
1 Parent(s): a009c3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -20
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
- Returns custom vote data for the specified universe IDs
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
- # 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",
@@ -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)