add filename option
This commit is contained in:
parent
dc3503a407
commit
dfaef09ccb
7
main.py
7
main.py
@ -92,7 +92,7 @@ def make_wallpaper(
|
|||||||
size: float = 3,
|
size: float = 3,
|
||||||
fileformat: str = "svg",
|
fileformat: str = "svg",
|
||||||
orientation: str = "landscape",
|
orientation: str = "landscape",
|
||||||
local: bool = False,
|
filename: str = "",
|
||||||
markers: str = ".",
|
markers: str = ".",
|
||||||
perlin: bool = True,
|
perlin: bool = True,
|
||||||
):
|
):
|
||||||
@ -163,14 +163,13 @@ def make_wallpaper(
|
|||||||
pad_inches=0,
|
pad_inches=0,
|
||||||
)
|
)
|
||||||
buf.seek(0)
|
buf.seek(0)
|
||||||
if local:
|
if filename:
|
||||||
filename = f"speckles.{fileformat}"
|
|
||||||
with open(filename, "wb") as f:
|
with open(filename, "wb") as f:
|
||||||
f.write(buf.getbuffer())
|
f.write(buf.getbuffer())
|
||||||
|
buf.close()
|
||||||
return filename
|
return filename
|
||||||
else:
|
else:
|
||||||
return StreamingResponse(content=buf, media_type=MEDIA_TYPES[fileformat])
|
return StreamingResponse(content=buf, media_type=MEDIA_TYPES[fileformat])
|
||||||
buf.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user