Geek7 commited on
Commit
0d888dd
Β·
verified Β·
1 Parent(s): a16bfda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +191 -36
app.py CHANGED
@@ -1,36 +1,191 @@
1
- import gradio as gr
2
- import zipfile
3
- import os
4
- import time
5
-
6
- # Hardcoded paths
7
- ZIP_FILE_PATH = "ipv4/IP2PROXY-LITE-PX2.BIN.zip" # ZIP file location
8
- EXTRACT_FOLDER = "ipv4/" # Extraction folder
9
- os.makedirs(EXTRACT_FOLDER, exist_ok=True)
10
-
11
- # Extract function
12
- def extract_zip():
13
- if not os.path.exists(ZIP_FILE_PATH):
14
- return f"❌ ZIP file not found: {ZIP_FILE_PATH}"
15
-
16
- with zipfile.ZipFile(ZIP_FILE_PATH, 'r') as zip_ref:
17
- files = zip_ref.namelist()
18
- total_files = len(files)
19
-
20
- for i, file in enumerate(files):
21
- zip_ref.extract(file, EXTRACT_FOLDER)
22
- time.sleep(0.1) # Simulate progress
23
-
24
- return f"βœ… Extracted to {EXTRACT_FOLDER}"
25
-
26
- # Gradio UI
27
- iface = gr.Interface(
28
- fn=extract_zip,
29
- inputs=[],
30
- outputs="text",
31
- live=True,
32
- title="ZIP Extractor",
33
- description="Click the button to extract a ZIP file."
34
- )
35
-
36
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, jsonify
2
+
3
+ from flask_cors import CORS
4
+
5
+ import subprocess
6
+
7
+ import IP2Location
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ app = Flask(__name__)
22
+
23
+ CORS(app) # Enable CORS for all routes
24
+
25
+
26
+
27
+
28
+
29
+ @app.route('/')
30
+
31
+ def home():
32
+
33
+ return ""
34
+
35
+
36
+
37
+ # Define ECPM values for different countries based on timezones
38
+
39
+ ECPM_VALUES = {
40
+
41
+ "America/New_York": 60, # USA (Eastern)
42
+
43
+ "America/Chicago": 58, # USA (Central)
44
+
45
+ "America/Denver": 55, # USA (Mountain)
46
+
47
+ "America/Los_Angeles": 52, # USA (Pacific)
48
+
49
+ "Europe/London": 70, # UK
50
+
51
+ "Europe/Paris": 65, # France
52
+
53
+ "Europe/Berlin": 67, # Germany
54
+
55
+ "Europe/Zurich": 66, # Switzerland
56
+
57
+ "Europe/Copenhagen": 64, # Denmark
58
+
59
+ "Europe/Madrid": 63, # Spain
60
+
61
+ "Europe/Rome": 62, # Italy
62
+
63
+ "Europe/Stockholm": 68, # Sweden
64
+
65
+ "Europe/Oslo": 69, # Norway
66
+
67
+ "America/Sao_Paulo": 45, # Brazil
68
+
69
+ "Australia/Sydney": 75, # Australia
70
+
71
+ "Europe/Chisinau": 55, # Moldova
72
+
73
+ "Europe/Amsterdam": 66, # Netherlands
74
+
75
+ "Europe/Lisbon": 61, # Portugal
76
+
77
+ "Europe/Brussels": 64, # Belgium
78
+
79
+ "Pacific/Auckland": 80 # New Zealand
80
+
81
+ }
82
+
83
+
84
+
85
+ @app.route('/get_ecpm_player', methods=['GET'])
86
+
87
+ def get_ecpm():
88
+
89
+ # Get timezone from request
90
+
91
+ user_timezone = request.args.get('timezone', 'Unknown')
92
+
93
+
94
+
95
+ # Get corresponding ECPM value
96
+
97
+ ecpm_value = ECPM_VALUES.get(user_timezone, 50) # Default to 50 if not found
98
+
99
+
100
+
101
+ return jsonify({"ecpm": ecpm_value, "timezone": user_timezone})
102
+
103
+
104
+
105
+ @app.route('/get-ip', methods=['GET'])
106
+
107
+ def get_ip():
108
+
109
+ user_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
110
+
111
+ return jsonify({"ip": user_ip, "type": "IPv6" if ":" in user_ip else "IPv4"})
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ @app.route('/get_latest_version', methods=['GET'])
122
+
123
+ def get_latest_version():
124
+
125
+ latest_version = "31.0" # Use snake_case for internal Python variables
126
+
127
+ return jsonify({'latestVersion': latest_version}) # Use camelCase in JSON response
128
+
129
+
130
+
131
+ @app.route('/get_latest_version2', methods=['GET'])
132
+
133
+ def get_latest_version2():
134
+
135
+ latest_version = "7.0" # Use snake_case for internal Python variables
136
+
137
+ return jsonify({'latestVersion': latest_version}) # Use camelCase in JSON response
138
+
139
+
140
+
141
+
142
+
143
+ # API endpoint returning hardcoded features
144
+
145
+ @app.route('/api/features')
146
+
147
+ def get_features():
148
+
149
+ features = [
150
+
151
+ # {"name": "πŸš€ Fast", "description": "Quick response time with optimized performance."}
152
+
153
+
154
+
155
+
156
+
157
+ ]
158
+
159
+ return jsonify(features)
160
+
161
+
162
+
163
+ # API endpoint returning hardcoded features
164
+
165
+ @app.route('/api/features2')
166
+
167
+ def get_features2():
168
+
169
+ features = [
170
+
171
+ # {"name": "πŸš€ Fast", "description": "Quick response time with optimized performance."}
172
+
173
+
174
+
175
+
176
+
177
+ ]
178
+
179
+ return jsonify(features)
180
+
181
+
182
+
183
+
184
+
185
+ if __name__ == '__main__':
186
+
187
+ subprocess.Popen(["python", "wk.py"]) # Start awake.py
188
+
189
+
190
+
191
+ app.run(host='0.0.0.0', port=7860)