SimpleChatTC:SimpleProxy: Extract and check path, route to handlers

This commit is contained in:
hanishkvc 2025-10-16 18:39:02 +05:30
parent c99788e290
commit 73054a5832
1 changed files with 23 additions and 1 deletions

View File

@ -9,6 +9,7 @@
import sys
import http.server
import urllib.parse
gMe = {
@ -19,9 +20,30 @@ gMe = {
class ProxyHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
print(self.path)
print(f"DBUG:ProxyHandler:{self.path}")
pr = urllib.parse.urlparse(self.path)
print(f"DBUG:ProxyHandler:{pr}")
match pr.path:
case '/urlraw':
handle_urlraw(self, pr)
case '/urltext':
handle_urltext(self, pr)
case _:
print(f"WARN:ProxyHandler:UnknownPath{pr.path}")
self.send_response(400)
self.send_header('Content-Type', 'plain/text')
self.end_headers()
self.wfile.write(f"WARN:UnknownPath:{pr.path}")
def handle_urlraw(ph: ProxyHandler, pr: urllib.parse.ParseResult):
print(f"DBUG:HandleUrlRaw:{pr}")
queryParams = urllib.parse.parse_qs(pr.query)
def handle_urltext(ph: ProxyHandler, pr: urllib.parse.ParseResult):
print(f"DBUG:HandleUrlText:{pr}")
def process_args(args: list[str]):
global gMe