Update post_methods.py
Browse files- post_methods.py +10 -16
post_methods.py
CHANGED
|
@@ -1,27 +1,21 @@
|
|
| 1 |
-
from
|
| 2 |
-
from database import get_db
|
| 3 |
|
| 4 |
def add_user():
|
| 5 |
-
"""Yeni kullanıcı ekler"""
|
| 6 |
try:
|
| 7 |
if not request.json or "name" not in request.json:
|
| 8 |
return jsonify({"error": "İsim zorunlu alan"}), 400
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
|
| 18 |
return jsonify({
|
| 19 |
-
"message": "Kullanıcı eklendi",
|
| 20 |
-
"user":
|
| 21 |
-
"id": cursor.lastrowid,
|
| 22 |
-
"name": request.json["name"],
|
| 23 |
-
"score": request.json.get("score", 0)
|
| 24 |
-
}
|
| 25 |
}), 201
|
| 26 |
|
| 27 |
except Exception as e:
|
|
|
|
| 1 |
+
from dataset_manager import save_to_dataset
|
|
|
|
| 2 |
|
| 3 |
def add_user():
|
|
|
|
| 4 |
try:
|
| 5 |
if not request.json or "name" not in request.json:
|
| 6 |
return jsonify({"error": "İsim zorunlu alan"}), 400
|
| 7 |
|
| 8 |
+
user_data = {
|
| 9 |
+
"name": request.json["name"],
|
| 10 |
+
"score": request.json.get("score", 0),
|
| 11 |
+
"timestamp": datetime.now().isoformat()
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
save_to_dataset(user_data) # Dataset'e kaydet
|
| 15 |
|
| 16 |
return jsonify({
|
| 17 |
+
"message": "Kullanıcı dataset'e eklendi",
|
| 18 |
+
"user": user_data
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}), 201
|
| 20 |
|
| 21 |
except Exception as e:
|