Opera8 commited on
Commit
8cefa2b
·
verified ·
1 Parent(s): fcfbfab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -28
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
- <title>AI Model Status</title>
11
- <style>
12
- body { font-family: sans-serif; text-align: center; padding: 50px; background-color: #f0f0f0; }
13
- h1 { color: #333; }
14
- .status { color: green; font-weight: bold; }
15
- </style>
 
16
  </head>
17
  <body>
18
- <h1>AI Inference Engine</h1>
19
- <p>Status: <span class="status">OPERATIONAL</span></p>
20
- <p>Model loaded: GPT-Neo-1.3B</p>
21
- <p>Waiting for API requests...</p>
 
 
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
- # 3. تابعی برای اجرای وب‌سایت الکی روی پورت 3000
77
- def run_fake_website():
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
- # 4. اجرای سای در پس‌زمینه
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"])