Serve SVG files directly (#107)

This commit is contained in:
Christian Byrne 2025-05-01 20:01:41 -07:00 committed by Robin Huang
parent 09d0fd132c
commit 491c020f45

View File

@ -417,6 +417,17 @@ class PromptServer():
if os.path.isfile(file): if os.path.isfile(file):
if 'preview' in request.rel_url.query: if 'preview' in request.rel_url.query:
extension = os.path.splitext(filename)[-1]
if extension and extension.lower() == ".svg":
with open(file, "r") as f:
return web.Response(
body=f.read(),
content_type="image/svg+xml",
headers={
"Content-Disposition": f'filename="{filename}"'
},
)
with Image.open(file) as img: with Image.open(file) as img:
preview_info = request.rel_url.query['preview'].split(';') preview_info = request.rel_url.query['preview'].split(';')
image_format = preview_info[0] image_format = preview_info[0]