Clip off ".json" from story name when downloading

This commit is contained in:
Gnome Ann 2021-09-01 14:07:56 -04:00
parent 7e1b1add11
commit 24d57a7ac3
1 changed files with 8 additions and 2 deletions

View File

@ -507,7 +507,10 @@ def download():
if(save_format == "plaintext"):
txt = vars.prompt + "".join(vars.actions.values())
save = Response(txt)
save.headers.set('Content-Disposition', 'attachment', filename='%s.txt' % path.basename(vars.savedir))
filename = path.basename(vars.savedir)
if filename[-5:] == ".json":
filename = filename[:-5]
save.headers.set('Content-Disposition', 'attachment', filename='%s.txt' % filename)
return(save)
# Build json to write
@ -531,7 +534,10 @@ def download():
})
save = Response(json.dumps(js, indent=3))
save.headers.set('Content-Disposition', 'attachment', filename='%s.json' % path.basename(vars.savedir))
filename = path.basename(vars.savedir)
if filename[-5:] == ".json":
filename = filename[:-5]
save.headers.set('Content-Disposition', 'attachment', filename='%s.json' % filename)
return(save)
#============================ METHODS =============================#