Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, jsonify
|
| 2 |
import time
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
|
@@ -233,7 +233,12 @@ def get_or_create_account(platform, udid):
|
|
| 233 |
@app.route('/update/account/<udid>', methods=['POST'])
|
| 234 |
def update_account_by_udid(udid):
|
| 235 |
try:
|
| 236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
incoming_data = request.get_json()
|
| 238 |
|
| 239 |
# UDID'ye göre hesabı bul
|
|
@@ -242,41 +247,29 @@ def update_account_by_udid(udid):
|
|
| 242 |
if not account:
|
| 243 |
return jsonify({
|
| 244 |
"success": False,
|
| 245 |
-
"object": None,
|
| 246 |
"error": "Account not found"
|
| 247 |
}), 404
|
| 248 |
|
| 249 |
-
#
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
|
| 257 |
-
#
|
| 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 |
-
|
| 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 |
|
|
|
|
| 1 |
+
from flask import Flask, jsonify, request
|
| 2 |
import time
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
|
|
|
| 233 |
@app.route('/update/account/<udid>', methods=['POST'])
|
| 234 |
def update_account_by_udid(udid):
|
| 235 |
try:
|
| 236 |
+
if not request.is_json:
|
| 237 |
+
return jsonify({
|
| 238 |
+
"success": False,
|
| 239 |
+
"error": "Content-Type must be application/json"
|
| 240 |
+
}), 400
|
| 241 |
+
|
| 242 |
incoming_data = request.get_json()
|
| 243 |
|
| 244 |
# UDID'ye göre hesabı bul
|
|
|
|
| 247 |
if not account:
|
| 248 |
return jsonify({
|
| 249 |
"success": False,
|
|
|
|
| 250 |
"error": "Account not found"
|
| 251 |
}), 404
|
| 252 |
|
| 253 |
+
# Güncelleme işlemleri
|
| 254 |
+
if 'credit' in incoming_data:
|
| 255 |
+
account['credit'] = int(incoming_data['credit'])
|
| 256 |
+
if 'level' in incoming_data:
|
| 257 |
+
account['level'] = int(incoming_data['level'])
|
| 258 |
+
if 'platform' in incoming_data:
|
| 259 |
+
account['platform'] = incoming_data['platform'].upper()
|
| 260 |
|
| 261 |
+
account['timestamp'] = int(time.time()) # Güncelleme zamanı
|
|
|
|
| 262 |
|
|
|
|
| 263 |
return jsonify({
|
| 264 |
"success": True,
|
| 265 |
"object": {
|
| 266 |
+
"account": account
|
| 267 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
})
|
| 269 |
|
| 270 |
except Exception as e:
|
| 271 |
return jsonify({
|
| 272 |
"success": False,
|
|
|
|
| 273 |
"error": str(e)
|
| 274 |
}), 500
|
| 275 |
|