|
from flask import Flask, jsonify |
|
from flask_cors import CORS |
|
import subprocess |
|
import IP2Location |
|
|
|
|
|
|
|
|
|
app = Flask(__name__) |
|
CORS(app) |
|
|
|
|
|
IPV4_BIN = "PX2.LITE.IPV4.BIN" |
|
IPV6_BIN = "PX2.LITE.IPV6.BIN" |
|
|
|
db_ipv4 = IP2Location.IP2Location(IPV4_BIN) |
|
db_ipv6 = IP2Location.IP2Location(IPV6_BIN) |
|
|
|
|
|
@app.route('/') |
|
def home(): |
|
return "" |
|
|
|
|
|
ECPM_VALUES = { |
|
"America/New_York": 60, |
|
"America/Chicago": 58, |
|
"America/Denver": 55, |
|
"America/Los_Angeles": 52, |
|
"Europe/London": 70, |
|
"Europe/Paris": 65, |
|
"Europe/Berlin": 67, |
|
"Europe/Zurich": 66, |
|
"Europe/Copenhagen": 64, |
|
"Europe/Madrid": 63, |
|
"Europe/Rome": 62, |
|
"Europe/Stockholm": 68, |
|
"Europe/Oslo": 69, |
|
"America/Sao_Paulo": 45, |
|
"Australia/Sydney": 75, |
|
"Europe/Chisinau": 55, |
|
"Europe/Amsterdam": 66, |
|
"Europe/Lisbon": 61, |
|
"Europe/Brussels": 64, |
|
"Pacific/Auckland": 80 |
|
} |
|
|
|
@app.route('/get_ecpm_player', methods=['GET']) |
|
def get_ecpm(): |
|
|
|
user_timezone = request.args.get('timezone', 'Unknown') |
|
|
|
|
|
ecpm_value = ECPM_VALUES.get(user_timezone, 50) |
|
|
|
return jsonify({"ecpm": ecpm_value, "timezone": user_timezone}) |
|
|
|
def check_proxy(ip): |
|
try: |
|
db = db_ipv6 if ":" in ip else db_ipv4 |
|
record = db.get_all(ip) |
|
|
|
proxy_type = record.proxy_type |
|
return proxy_type not in ["", "-"] |
|
except Exception as e: |
|
print(f"Error checking IP: {e}") |
|
return False |
|
|
|
@app.route("/check-ip", methods=["GET"]) |
|
def check_ip(): |
|
user_ip = request.headers.get("X-Forwarded-For", request.remote_addr) |
|
is_proxy = check_proxy(user_ip) |
|
|
|
return jsonify({ |
|
"ip": user_ip, |
|
"proxy_detected": is_proxy |
|
}) |
|
|
|
|
|
|
|
@app.route('/get_latest_version', methods=['GET']) |
|
def get_latest_version(): |
|
latest_version = "31.0" |
|
return jsonify({'latestVersion': latest_version}) |
|
|
|
@app.route('/get_latest_version2', methods=['GET']) |
|
def get_latest_version2(): |
|
latest_version = "7.0" |
|
return jsonify({'latestVersion': latest_version}) |
|
|
|
|
|
|
|
@app.route('/api/features') |
|
def get_features(): |
|
features = [ |
|
|
|
|
|
|
|
] |
|
return jsonify(features) |
|
|
|
|
|
@app.route('/api/features2') |
|
def get_features2(): |
|
features = [ |
|
|
|
|
|
|
|
] |
|
return jsonify(features) |
|
|
|
|
|
if __name__ == '__main__': |
|
subprocess.Popen(["python", "wk.py"]) |
|
|
|
app.run(host='0.0.0.0', port=7860) |