yusufgundogdu commited on
Commit
1d9ece6
·
verified ·
1 Parent(s): da1b623

Create get_methods.py

Browse files
Files changed (1) hide show
  1. get_methods.py +13 -0
get_methods.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import jsonify
2
+ import random
3
+ from shared_data import shared_data
4
+
5
+ def get_users():
6
+ return jsonify({"users": shared_data["users"]})
7
+
8
+ def random_model():
9
+ return jsonify({"selected_model": random.choice(shared_data["models"])})
10
+
11
+ def get_user(user_id):
12
+ user = next((u for u in shared_data["users"] if u["id"] == user_id), None)
13
+ return jsonify(user) if user else (jsonify({"error": "User not found"}), 404)