sfun commited on
Commit
90475ed
1 Parent(s): 0c67134

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import re
2
  import yaml
3
  import requests
 
4
  from http.server import HTTPServer, BaseHTTPRequestHandler
5
  from urllib.parse import urlparse, parse_qs
6
 
@@ -42,6 +43,10 @@ def extract_and_transform_proxies(input_text):
42
  return "\n".join(transformed_proxies) if transformed_proxies else "未找到有效的SS代理配置"
43
 
44
  class RequestHandler(BaseHTTPRequestHandler):
 
 
 
 
45
  def do_GET(self):
46
  parsed_path = urlparse(self.path)
47
  query_params = parse_qs(parsed_path.query)
@@ -85,6 +90,7 @@ class RequestHandler(BaseHTTPRequestHandler):
85
  def run_server(port=8080):
86
  server_address = ('', port)
87
  httpd = HTTPServer(server_address, RequestHandler)
 
88
  print(f"Server running on port {port}")
89
  httpd.serve_forever()
90
 
 
1
  import re
2
  import yaml
3
  import requests
4
+ import datetime
5
  from http.server import HTTPServer, BaseHTTPRequestHandler
6
  from urllib.parse import urlparse, parse_qs
7
 
 
43
  return "\n".join(transformed_proxies) if transformed_proxies else "未找到有效的SS代理配置"
44
 
45
  class RequestHandler(BaseHTTPRequestHandler):
46
+ def log_request(self, code='-', size='-'):
47
+ timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
48
+ print(f"{timestamp} - {self.client_address[0]} - \"{self.requestline}\" {code} {size}")
49
+
50
  def do_GET(self):
51
  parsed_path = urlparse(self.path)
52
  query_params = parse_qs(parsed_path.query)
 
90
  def run_server(port=8080):
91
  server_address = ('', port)
92
  httpd = HTTPServer(server_address, RequestHandler)
93
+ print(f"===== Application Startup at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} =====")
94
  print(f"Server running on port {port}")
95
  httpd.serve_forever()
96