Clean up code for saving story as plaintext
This commit is contained in:
parent
543acf9ba4
commit
8ae9304cda
27
aiserver.py
27
aiserver.py
|
@ -504,19 +504,7 @@ def download():
|
||||||
save_format = request.args.get("format", "json").strip().lower()
|
save_format = request.args.get("format", "json").strip().lower()
|
||||||
|
|
||||||
if(save_format == "plaintext"):
|
if(save_format == "plaintext"):
|
||||||
ln = len(vars.actions)
|
txt = vars.prompt + "".join(vars.actions.values())
|
||||||
|
|
||||||
if(ln > 0):
|
|
||||||
chunks = collections.deque()
|
|
||||||
for key in reversed(vars.actions):
|
|
||||||
chunk = vars.actions[key]
|
|
||||||
chunks.appendleft(chunk)
|
|
||||||
|
|
||||||
if(ln > 0):
|
|
||||||
txt = vars.prompt + "".join(chunks)
|
|
||||||
elif(ln == 0):
|
|
||||||
txt = vars.prompt
|
|
||||||
|
|
||||||
save = Response(txt)
|
save = Response(txt)
|
||||||
save.headers.set('Content-Disposition', 'attachment', filename='%s.txt' % path.basename(vars.savedir))
|
save.headers.set('Content-Disposition', 'attachment', filename='%s.txt' % path.basename(vars.savedir))
|
||||||
return(save)
|
return(save)
|
||||||
|
@ -1981,18 +1969,7 @@ def saveRequest(savpath):
|
||||||
"constant": wi["constant"]
|
"constant": wi["constant"]
|
||||||
})
|
})
|
||||||
|
|
||||||
ln = len(vars.actions)
|
txt = vars.prompt + "".join(vars.actions.values())
|
||||||
|
|
||||||
if(ln > 0):
|
|
||||||
chunks = collections.deque()
|
|
||||||
for key in reversed(vars.actions):
|
|
||||||
chunk = vars.actions[key]
|
|
||||||
chunks.appendleft(chunk)
|
|
||||||
|
|
||||||
if(ln > 0):
|
|
||||||
txt = vars.prompt + "".join(chunks)
|
|
||||||
elif(ln == 0):
|
|
||||||
txt = vars.prompt
|
|
||||||
|
|
||||||
# Write it
|
# Write it
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue