Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,31 +3,30 @@ import subprocess
|
|
| 3 |
import threading
|
| 4 |
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
| 5 |
|
| 6 |
-
html_content = """
|
| 7 |
-
<!DOCTYPE html>
|
| 8 |
<html>
|
| 9 |
<head>
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
</head>
|
| 17 |
<body>
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
</body>
|
| 23 |
-
</html>
|
| 24 |
-
"""
|
| 25 |
|
| 26 |
with open("index.html", "w") as f:
|
| 27 |
f.write(html_content)
|
| 28 |
|
| 29 |
-
# 2. تنظیمات Xray (همراه با Fallback به سایت الکی)
|
| 30 |
-
# هر ترافیکی که VPN نباشد، به پورت 3000 (سایت الکی) فرستاده میشود
|
| 31 |
xray_config = """
|
| 32 |
{
|
| 33 |
"log": {
|
|
@@ -73,19 +72,10 @@ xray_config = """
|
|
| 73 |
with open("config.json", "w") as f:
|
| 74 |
f.write(xray_config)
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
port = 3000
|
| 79 |
-
server_address = ("", port)
|
| 80 |
-
httpd = HTTPServer(server_address, SimpleHTTPRequestHandler)
|
| 81 |
-
print(f"Fake AI Site running on port {port}")
|
| 82 |
httpd.serve_forever()
|
| 83 |
|
| 84 |
-
|
| 85 |
-
thread = threading.Thread(target=run_fake_website)
|
| 86 |
-
thread.daemon = True
|
| 87 |
-
thread.start()
|
| 88 |
|
| 89 |
-
# 5. اجرای
|
| 90 |
-
print("Starting Xray Core...")
|
| 91 |
subprocess.run(["./xray", "-c", "config.json"])
|
|
|
|
| 3 |
import threading
|
| 4 |
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
| 5 |
|
| 6 |
+
html_content = """<!DOCTYPE html>
|
|
|
|
| 7 |
<html>
|
| 8 |
<head>
|
| 9 |
+
<title>Service Status</title>
|
| 10 |
+
<style>
|
| 11 |
+
body { font-family: sans-serif; text-align: center; padding-top: 50px; background-color: #f4f4f4; }
|
| 12 |
+
.box { background: white; padding: 40px; border-radius: 8px; display: inline-block; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
|
| 13 |
+
h1 { color: #2c3e50; }
|
| 14 |
+
.status { color: #27ae60; font-weight: bold; }
|
| 15 |
+
</style>
|
| 16 |
</head>
|
| 17 |
<body>
|
| 18 |
+
<div class="box">
|
| 19 |
+
<h1>AI Inference System</h1>
|
| 20 |
+
<p>Model: GPT-Transformer-v4</p>
|
| 21 |
+
<p>Status: <span class="status">OPERATIONAL</span></p>
|
| 22 |
+
<p>Latency: 12ms</p>
|
| 23 |
+
</div>
|
| 24 |
</body>
|
| 25 |
+
</html>"""
|
|
|
|
| 26 |
|
| 27 |
with open("index.html", "w") as f:
|
| 28 |
f.write(html_content)
|
| 29 |
|
|
|
|
|
|
|
| 30 |
xray_config = """
|
| 31 |
{
|
| 32 |
"log": {
|
|
|
|
| 72 |
with open("config.json", "w") as f:
|
| 73 |
f.write(xray_config)
|
| 74 |
|
| 75 |
+
def run_server():
|
| 76 |
+
httpd = HTTPServer(('127.0.0.1', 3000), SimpleHTTPRequestHandler)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
httpd.serve_forever()
|
| 78 |
|
| 79 |
+
threading.Thread(target=run_server, daemon=True).start()
|
|
|
|
|
|
|
|
|
|
| 80 |
|
|
|
|
|
|
|
| 81 |
subprocess.run(["./xray", "-c", "config.json"])
|