diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 26348c9..a4bc8db 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -701,25 +701,37 @@ class HttpHandler(BaseHTTPRequestHandler): try: static_path = os.path.join(os.path.dirname(__file__), 'static') - if url_split[2] == 'favicon-32.png': - self.putHeaders(status_code, 'image/png') - with open(os.path.join(static_path, 'favicon-32.png'), 'rb') as fp: + if len(url_split) > 3 and url_split[2] == 'sequence_diagrams': + with open(os.path.join(static_path, 'sequence_diagrams', url_split[3]), 'rb') as fp: + self.putHeaders(status_code, 'image/svg+xml') return fp.read() - elif url_split[2] == 'style.css': - self.putHeaders(status_code, 'text/css') - with open(os.path.join(static_path, 'style.css'), 'rb') as fp: + elif len(url_split) > 3 and url_split[2] == 'images': + filename = os.path.join(*url_split[3:]) + _, extension = os.path.splitext(filename) + mime_type = {'.svg': 'image/svg+xml', + '.png': 'image/png', + '.jpg': 'image/jpeg', + }.get(extension, '') + if mime_type == '': + raise ValueError('Unknown file type ' + filename) + with open(os.path.join(static_path, 'images', filename), 'rb') as fp: + self.putHeaders(status_code, mime_type) return fp.read() - elif len(url_split) > 3 and url_split[2] == 'sequence_diagrams': - self.putHeaders(status_code, 'image/svg+xml') - with open(os.path.join(static_path, 'sequence_diagrams', url_split[3]), 'rb') as fp: + elif len(url_split) > 3 and url_split[2] == 'css': + filename = os.path.join(*url_split[3:]) + with open(os.path.join(static_path, 'css', filename), 'rb') as fp: + self.putHeaders(status_code, 'text/css; charset=utf-8') return fp.read() else: self.putHeaders(status_code, 'text/html') return self.page_404(url_split) - except Exception as ex: + except FileNotFoundError: self.putHeaders(status_code, 'text/html') + return self.page_404(url_split) + except Exception as ex: if self.server.swap_client.debug is True: self.server.swap_client.log.error(traceback.format_exc()) + self.putHeaders(status_code, 'text/html') return self.page_error(str(ex)) try: diff --git a/basicswap/static/style.css b/basicswap/static/css/simple/style.css similarity index 100% rename from basicswap/static/style.css rename to basicswap/static/css/simple/style.css diff --git a/basicswap/static/favicon-32.png b/basicswap/static/images/favicon-32.png similarity index 100% rename from basicswap/static/favicon-32.png rename to basicswap/static/images/favicon-32.png diff --git a/basicswap/templates/automation_strategies.html b/basicswap/templates/automation_strategies.html index 3412c17..769a069 100644 --- a/basicswap/templates/automation_strategies.html +++ b/basicswap/templates/automation_strategies.html @@ -30,7 +30,7 @@
Name | Type |
---|---|
{{ s[1] }} | {{ s[2] }} |
{{ s[1] }} | {{ s[2] }} |