Geek7 commited on
Commit
57f037b
Β·
verified Β·
1 Parent(s): 7943307

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -118
app.py CHANGED
@@ -1,130 +1,44 @@
1
- from flask import Flask, jsonify
2
- from flask_cors import CORS
3
- import subprocess
4
- import IP2Location
5
  import zipfile
6
  import os
7
- import glob
8
 
 
 
 
 
9
 
 
 
 
10
 
 
 
11
 
 
 
 
 
 
12
 
13
- app = Flask(__name__)
14
- CORS(app) # Enable CORS for all routes
 
 
15
 
16
- # Load IPv4 & IPv6 databases (Download and place in same folder)
17
- #IPV4_BIN = "ipv4/IP2PROXY-LITE-PX2.BIN"
18
- #IPV6_BIN = "ipv6/IP2PROXY-LITE-PX2.BIN"
19
 
20
- #db_ipv4 = IP2Location.IP2Location(IPV4_BIN)
21
- #db_ipv6 = IP2Location.IP2Location(IPV6_BIN)
 
22
 
23
- zip_folder = "ipv4" # Change this to your folder
24
- extract_to = "ipv4"
25
 
26
- zip_files = glob.glob(os.path.join(zip_folder, "*.zip")) # Find all ZIPs
 
27
 
28
-
29
- @app.route('/')
30
- def home():
31
- return ""
32
-
33
- # Define ECPM values for different countries based on timezones
34
- ECPM_VALUES = {
35
- "America/New_York": 60, # USA (Eastern)
36
- "America/Chicago": 58, # USA (Central)
37
- "America/Denver": 55, # USA (Mountain)
38
- "America/Los_Angeles": 52, # USA (Pacific)
39
- "Europe/London": 70, # UK
40
- "Europe/Paris": 65, # France
41
- "Europe/Berlin": 67, # Germany
42
- "Europe/Zurich": 66, # Switzerland
43
- "Europe/Copenhagen": 64, # Denmark
44
- "Europe/Madrid": 63, # Spain
45
- "Europe/Rome": 62, # Italy
46
- "Europe/Stockholm": 68, # Sweden
47
- "Europe/Oslo": 69, # Norway
48
- "America/Sao_Paulo": 45, # Brazil
49
- "Australia/Sydney": 75, # Australia
50
- "Europe/Chisinau": 55, # Moldova
51
- "Europe/Amsterdam": 66, # Netherlands
52
- "Europe/Lisbon": 61, # Portugal
53
- "Europe/Brussels": 64, # Belgium
54
- "Pacific/Auckland": 80 # New Zealand
55
- }
56
-
57
- @app.route('/get_ecpm_player', methods=['GET'])
58
- def get_ecpm():
59
- # Get timezone from request
60
- user_timezone = request.args.get('timezone', 'Unknown')
61
-
62
- # Get corresponding ECPM value
63
- ecpm_value = ECPM_VALUES.get(user_timezone, 50) # Default to 50 if not found
64
-
65
- return jsonify({"ecpm": ecpm_value, "timezone": user_timezone})
66
-
67
- #def check_proxy(ip):
68
- # try:
69
- # db = db_ipv6 if ":" in ip else db_ipv4 # Use correct database
70
- # record = db.get_all(ip)
71
-
72
- # proxy_type = record.proxy_type
73
- # return proxy_type not in ["", "-"] # Proxy detected if type is not empty
74
- #except Exception as e:
75
- # print(f"Error checking IP: {e}")
76
- # return False
77
-
78
- #@app.route("/check-ip", methods=["GET"])
79
- #def check_ip():
80
- # user_ip = request.headers.get("X-Forwarded-For", request.remote_addr) # Get real IP
81
- # is_proxy = check_proxy(user_ip)
82
-
83
- # return jsonify({
84
- # "ip": user_ip,
85
- # "proxy_detected": is_proxy
86
- #})
87
-
88
-
89
- for zip_file in zip_files:
90
- with zipfile.ZipFile(zip_file, 'r') as zip_ref:
91
- zip_ref.extractall(extract_to)
92
- print(f"βœ… Extracted: {zip_file}")
93
-
94
-
95
- @app.route('/get_latest_version', methods=['GET'])
96
- def get_latest_version():
97
- latest_version = "31.0" # Use snake_case for internal Python variables
98
- return jsonify({'latestVersion': latest_version}) # Use camelCase in JSON response
99
-
100
- @app.route('/get_latest_version2', methods=['GET'])
101
- def get_latest_version2():
102
- latest_version = "7.0" # Use snake_case for internal Python variables
103
- return jsonify({'latestVersion': latest_version}) # Use camelCase in JSON response
104
-
105
-
106
- # API endpoint returning hardcoded features
107
- @app.route('/api/features')
108
- def get_features():
109
- features = [
110
- # {"name": "πŸš€ Fast", "description": "Quick response time with optimized performance."}
111
-
112
-
113
- ]
114
- return jsonify(features)
115
-
116
- # API endpoint returning hardcoded features
117
- @app.route('/api/features2')
118
- def get_features2():
119
- features = [
120
- # {"name": "πŸš€ Fast", "description": "Quick response time with optimized performance."}
121
-
122
-
123
- ]
124
- return jsonify(features)
125
-
126
-
127
- if __name__ == '__main__':
128
- subprocess.Popen(["python", "wk.py"]) # Start awake.py
129
-
130
- app.run(host='0.0.0.0', port=7860)
 
1
+ import tkinter as tk
2
+ from tkinter import filedialog, messagebox, ttk
 
 
3
  import zipfile
4
  import os
5
+ import threading
6
 
7
+ def extract_zip():
8
+ zip_file = filedialog.askopenfilename(filetypes=[("ZIP Files", "*.zip")])
9
+ if not zip_file:
10
+ return
11
 
12
+ extract_to = filedialog.askdirectory(title="Select Extract Folder")
13
+ if not extract_to:
14
+ return
15
 
16
+ progress["value"] = 0 # Reset progress bar
17
+ threading.Thread(target=extract_zip_thread, args=(zip_file, extract_to)).start()
18
 
19
+ def extract_zip_thread(zip_file, extract_to):
20
+ try:
21
+ with zipfile.ZipFile(zip_file, 'r') as zip_ref:
22
+ files = zip_ref.namelist()
23
+ total_files = len(files)
24
 
25
+ for i, file in enumerate(files):
26
+ zip_ref.extract(file, extract_to)
27
+ progress["value"] = ((i + 1) / total_files) * 100
28
+ root.update_idletasks()
29
 
30
+ messagebox.showinfo("Success", f"βœ… Extracted to: {extract_to}")
31
+ except Exception as e:
32
+ messagebox.showerror("Error", f"❌ Error: {e}")
33
 
34
+ # GUI Setup
35
+ root = tk.Tk()
36
+ root.title("ZIP Extractor")
37
 
38
+ button = tk.Button(root, text="Select ZIP & Extract", command=extract_zip)
39
+ button.pack(pady=10)
40
 
41
+ progress = ttk.Progressbar(root, orient="horizontal", length=300, mode="determinate")
42
+ progress.pack(pady=10)
43
 
44
+ root.mainloop()