Use entire, unprocessed (apart from stripping leading slashes) request path

main
Luca 3 years ago
parent 3464c58288
commit b9dbf443e5

@ -17,14 +17,13 @@
from http.server import BaseHTTPRequestHandler, HTTPServer from http.server import BaseHTTPRequestHandler, HTTPServer
from icalendar import Calendar from icalendar import Calendar
from schichtleiter.schedule import calendar_to_xml from schichtleiter.schedule import calendar_to_xml
from urllib.parse import unquote, urlparse
import requests import requests
import sys import sys
def run_server(address, port, urls): def run_server(address, port, urls):
class RequestHandler(BaseHTTPRequestHandler): class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self): def do_GET(self):
url = unquote(urlparse(self.path).path.lstrip('/')) url = self.path.lstrip('/')
if url not in urls: if url not in urls:
self.send_error(404) self.send_error(404)
return return

Loading…
Cancel
Save