Alok8383 commited on
Commit
56dda99
·
verified ·
1 Parent(s): 5c612fa

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ from flask_cors import CORS
3
+ import requests
4
+ import random
5
+
6
+ app = Flask(__name__)
7
+ CORS(app)
8
+
9
+ # --- 🔥 FIREBASE CONNECTION ---
10
+ # Tumhara Naya Database URL
11
+ DB_URL = "https://v1000-686c0-default-rtdb.firebaseio.com"
12
+
13
+ # --- 🔐 API 1: LOGIN CHECK (Via Firebase) ---
14
+ @app.route('/api/login', methods=['POST'])
15
+ def login():
16
+ data = request.json
17
+ user_key = data.get('key')
18
+
19
+ if not user_key:
20
+ return jsonify({"success": False, "message": "KEY MISSING"}), 400
21
+
22
+ # Firebase se poocho: "Kya ye Key 'users' folder mein hai?"
23
+ try:
24
+ # Hum seedha us key ka status check karenge
25
+ response = requests.get(f"{DB_URL}/users/{user_key}.json")
26
+ status = response.json() # Ye 'active' ya 'expired' return karega
27
+
28
+ if status == "active":
29
+ return jsonify({
30
+ "success": True,
31
+ "message": "ACCESS GRANTED",
32
+ "plan": "VIP MEMBER"
33
+ })
34
+ elif status == "expired":
35
+ return jsonify({"success": False, "message": "KEY EXPIRED"}), 403
36
+ else:
37
+ return jsonify({"success": False, "message": "INVALID KEY"}), 401
38
+
39
+ except Exception as e:
40
+ return jsonify({"success": False, "message": "SERVER ERROR"}), 500
41
+
42
+
43
+ # --- 🔮 API 2: PREDICTION LOGIC (Wahi Secret Formula) ---
44
+ @app.route('/api/predict', methods=['POST'])
45
+ def predict():
46
+ data = request.json
47
+ try:
48
+ last_period = int(data.get('last_period'))
49
+ except:
50
+ return jsonify({"prediction": "ERROR", "confidence": 0})
51
+
52
+ # --- SECRET LOGIC ---
53
+ last_digit = int(str(last_period)[-1])
54
+
55
+ # Logic: 60% Pattern, 40% Random
56
+ chance = random.randint(1, 100)
57
+
58
+ if chance > 40:
59
+ if last_digit in [0, 2, 4, 6, 8]:
60
+ prediction = "SMALL" # Red
61
+ else:
62
+ prediction = "BIG" # Green
63
+ else:
64
+ prediction = random.choice(["BIG", "SMALL"])
65
+
66
+ return jsonify({
67
+ "period": last_period + 1,
68
+ "prediction": prediction,
69
+ "confidence": random.randint(88, 99)
70
+ })
71
+
72
+ if __name__ == '__main__':
73
+ app.run(host='0.0.0.0', port=7860)
74
+