add filename option

This commit is contained in:
julius 2024-10-21 13:32:10 +02:00
parent dc3503a407
commit dfaef09ccb
Signed by: julius
GPG Key ID: C80A63E6A5FD7092

View File

@ -92,7 +92,7 @@ def make_wallpaper(
size: float = 3,
fileformat: str = "svg",
orientation: str = "landscape",
local: bool = False,
filename: str = "",
markers: str = ".",
perlin: bool = True,
):
@ -163,14 +163,13 @@ def make_wallpaper(
pad_inches=0,
)
buf.seek(0)
if local:
filename = f"speckles.{fileformat}"
if filename:
with open(filename, "wb") as f:
f.write(buf.getbuffer())
buf.close()
return filename
else:
return StreamingResponse(content=buf, media_type=MEDIA_TYPES[fileformat])
buf.close()
if __name__ == "__main__":