SimpleChatTC:SimpleProxy:Options just in case
This commit is contained in:
parent
9c7d6cc0e4
commit
9ff2c596ee
|
|
@ -23,19 +23,29 @@ gMe = {
|
||||||
|
|
||||||
class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
||||||
|
|
||||||
|
# Handle GET requests
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
print(f"DBUG:ProxyHandler:{self.path}")
|
print(f"DBUG:ProxyHandler:GET:{self.path}")
|
||||||
pr = urllib.parse.urlparse(self.path)
|
pr = urllib.parse.urlparse(self.path)
|
||||||
print(f"DBUG:ProxyHandler:{pr}")
|
print(f"DBUG:ProxyHandler:GET:{pr}")
|
||||||
match pr.path:
|
match pr.path:
|
||||||
case '/urlraw':
|
case '/urlraw':
|
||||||
handle_urlraw(self, pr)
|
handle_urlraw(self, pr)
|
||||||
case '/urltext':
|
case '/urltext':
|
||||||
handle_urltext(self, pr)
|
handle_urltext(self, pr)
|
||||||
case _:
|
case _:
|
||||||
print(f"WARN:ProxyHandler:UnknownPath{pr.path}")
|
print(f"WARN:ProxyHandler:GET:UnknownPath{pr.path}")
|
||||||
self.send_error(400, f"WARN:UnknownPath:{pr.path}")
|
self.send_error(400, f"WARN:UnknownPath:{pr.path}")
|
||||||
|
|
||||||
|
# Handle OPTIONS for CORS preflights (just in case from browser)
|
||||||
|
def do_OPTIONS(self):
|
||||||
|
print(f"DBUG:ProxyHandler:OPTIONS:{self.path}")
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Access-Control-Allow-Origin', '*')
|
||||||
|
self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS')
|
||||||
|
self.send_header('Access-Control-Allow-Headers', '*')
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class UrlReqResp:
|
class UrlReqResp:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue