Update app.py
Browse files
app.py
CHANGED
|
@@ -230,41 +230,56 @@ def get_or_create_account(platform, udid):
|
|
| 230 |
}), 201
|
| 231 |
|
| 232 |
|
| 233 |
-
@app.route('/account
|
| 234 |
-
def
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
return jsonify({
|
| 243 |
"success": False,
|
| 244 |
"object": None,
|
| 245 |
-
"error":
|
| 246 |
-
}),
|
| 247 |
-
|
| 248 |
-
# Sadece request'te gelen alanları güncelle (diğerlerine ve timestamp'e dokunma)
|
| 249 |
-
for field in ['credit', 'level', 'platform', 'udid']: # Güncellenebilir alanlar
|
| 250 |
-
if field in incoming_data:
|
| 251 |
-
account[field] = incoming_data[field]
|
| 252 |
-
|
| 253 |
-
# Güncellenmiş hesabı döndür (timestamp otomatik korunur)
|
| 254 |
-
return jsonify({
|
| 255 |
-
"success": True,
|
| 256 |
-
"object": {
|
| 257 |
-
"account": {
|
| 258 |
-
"id": account["id"],
|
| 259 |
-
"timestamp": account["timestamp"], # Orjinal değer korunur
|
| 260 |
-
"udid": account["udid"],
|
| 261 |
-
"platform": account["platform"],
|
| 262 |
-
"credit": account["credit"],
|
| 263 |
-
"level": account["level"]
|
| 264 |
-
}
|
| 265 |
-
},
|
| 266 |
-
"error": None
|
| 267 |
-
})
|
| 268 |
|
| 269 |
@app.route('/generate_list', methods=['GET'])
|
| 270 |
def get_generate_list():
|
|
|
|
| 230 |
}), 201
|
| 231 |
|
| 232 |
|
| 233 |
+
@app.route('/update/account/<udid>', methods=['POST'])
|
| 234 |
+
def update_account_by_udid(udid):
|
| 235 |
+
try:
|
| 236 |
+
# Request body'den gelen verileri al
|
| 237 |
+
incoming_data = request.get_json()
|
| 238 |
+
|
| 239 |
+
# UDID'ye göre hesabı bul
|
| 240 |
+
account = next((acc for acc in fake_db["accounts"] if acc["udid"] == udid), None)
|
| 241 |
+
|
| 242 |
+
if not account:
|
| 243 |
+
return jsonify({
|
| 244 |
+
"success": False,
|
| 245 |
+
"object": None,
|
| 246 |
+
"error": "Account not found"
|
| 247 |
+
}), 404
|
| 248 |
+
|
| 249 |
+
# Güncellenebilir alanlar
|
| 250 |
+
updatable_fields = ['credit', 'level', 'platform']
|
| 251 |
+
|
| 252 |
+
# Sadece request'te gelen ve güncellenebilir olan alanları güncelle
|
| 253 |
+
for field in updatable_fields:
|
| 254 |
+
if field in incoming_data:
|
| 255 |
+
account[field] = incoming_data[field]
|
| 256 |
+
|
| 257 |
+
# Timestamp'i güncelle
|
| 258 |
+
account['timestamp'] = int(time.time())
|
| 259 |
+
|
| 260 |
+
# Güncellenmiş hesabı döndür
|
| 261 |
+
return jsonify({
|
| 262 |
+
"success": True,
|
| 263 |
+
"object": {
|
| 264 |
+
"account": {
|
| 265 |
+
"id": account["id"],
|
| 266 |
+
"timestamp": account["timestamp"],
|
| 267 |
+
"udid": account["udid"],
|
| 268 |
+
"platform": account["platform"],
|
| 269 |
+
"credit": account["credit"],
|
| 270 |
+
"level": account["level"]
|
| 271 |
+
}
|
| 272 |
+
},
|
| 273 |
+
"error": None
|
| 274 |
+
})
|
| 275 |
+
|
| 276 |
+
except Exception as e:
|
| 277 |
return jsonify({
|
| 278 |
"success": False,
|
| 279 |
"object": None,
|
| 280 |
+
"error": str(e)
|
| 281 |
+
}), 500
|
| 282 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
@app.route('/generate_list', methods=['GET'])
|
| 285 |
def get_generate_list():
|