web-in-python-lol 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,13 +48,25 @@ class ShadowEngine(BaseHTTPRequestHandler):
48
48
  self.send_response(303); self.send_header('Location', self.headers.get('Referer', '/')); self.end_headers()
49
49
 
50
50
  def handle_request(self):
51
+ # Get the Host (e.g., 'blog.lmcworld.com:8080' or 'localhost:8080')
52
+ host = self.headers.get('Host', '')
53
+ subdomain = host.split('.')[0] if '.' in host else 'www'
54
+
55
+ # Optional: If you are running locally (localhost), the split might catch 'localhost'
56
+ if 'localhost' in subdomain or '127.0.0.1' in subdomain:
57
+ subdomain = 'www'
58
+
51
59
  func, args = self.find_route(urlparse(self.path).path)
52
60
  params = {k: v[0] for k, v in parse_qs(urlparse(self.path).query).items()}
61
+
53
62
  self.send_response(200); self.send_header("Content-type", "text/html"); self.end_headers()
63
+
54
64
  try:
55
- content = func(self.server.app_instance, params, *args) if func else "<h1>404</h1>"
56
- except:
65
+ # Pass the detected subdomain into your page function
66
+ content = func(self.server.app_instance, params, subdomain, *args) if func else "<h1>404</h1>"
67
+ except Exception:
57
68
  content = f"<pre style='color:red;'>{traceback.format_exc()}</pre>"
69
+
58
70
  self.wfile.write(self.server.app_instance._wrap(content).encode())
59
71
 
60
72
  def find_route(self, path):
@@ -7,4 +7,7 @@ setup(
7
7
  author="Basel Ezzat",
8
8
  packages=find_packages(),
9
9
  install_requires=[], # Since you used only standard libs, keep this empty!
10
- )
10
+ )
11
+
12
+ # python -m build
13
+ #python -m twine upload dist/*
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: web-in-python-lol
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A responsive, Python-only UI engine for rapid dashboards
5
5
  Author-email: Basel Ezzat <lmcteam206@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "web-in-python-lol"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  authors = [
9
9
  { name="Basel Ezzat", email="lmcteam206@gmail.com" },
10
10
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: web-in-python-lol
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A responsive, Python-only UI engine for rapid dashboards
5
5
  Author-email: Basel Ezzat <lmcteam206@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3