Browse Source

fix svg contenttype

pull/133/head
Weilbyte 2 years ago
parent
commit
85cb7540fc
No known key found for this signature in database GPG Key ID: E1EB2BFCF73B5B9F
  1. 8
      PVEDiscordDark/serve.py

8
PVEDiscordDark/serve.py

@ -37,12 +37,18 @@ class Server(BaseHTTPRequestHandler):
elif ext == "js":
data = open(os.path.join(DIR_JS, "PVEDiscordDark.js"), "rb").read()
type = "application/javascript"
elif ext == "png" or ext == "jpg" or ext == "jpeg" or ext == "svg":
elif ext == "png" or ext == "jpg" or ext == "jpeg":
try:
data = open(os.path.join(DIR_IMAGES, file), "rb").read()
type = f"image/{ext}"
except FileNotFoundError:
status = 404
elif ext == "svg":
try:
data = open(os.path.join(DIR_IMAGES, file), "rb").read()
type = f"image/svg+xml"
except FileNotFoundError:
status = 404
else:
status = 400
self._set_headers(status, type)

Loading…
Cancel
Save