Foundation for in browser downloading
This adds /download as a URL to immediately download the file, this will allow html changes that initiate a file download.
This commit is contained in:
parent
55059bddcf
commit
9b3e298089
27
aiserver.py
27
aiserver.py
|
@ -491,6 +491,33 @@ else:
|
||||||
@app.route('/index')
|
@app.route('/index')
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
@app.route('/download')
|
||||||
|
def download():
|
||||||
|
# Leave Edit/Memory mode before continuing
|
||||||
|
exitModes()
|
||||||
|
|
||||||
|
# Build json to write
|
||||||
|
js = {}
|
||||||
|
js["gamestarted"] = vars.gamestarted
|
||||||
|
js["prompt"] = vars.prompt
|
||||||
|
js["memory"] = vars.memory
|
||||||
|
js["authorsnote"] = vars.authornote
|
||||||
|
js["actions"] = tuple(vars.actions.values())
|
||||||
|
js["worldinfo"] = []
|
||||||
|
|
||||||
|
# Extract only the important bits of WI
|
||||||
|
for wi in vars.worldinfo:
|
||||||
|
if(wi["constant"] or wi["key"] != ""):
|
||||||
|
js["worldinfo"].append({
|
||||||
|
"key": wi["key"],
|
||||||
|
"keysecondary": wi["keysecondary"],
|
||||||
|
"content": wi["content"],
|
||||||
|
"selective": wi["selective"],
|
||||||
|
"constant": wi["constant"]
|
||||||
|
})
|
||||||
|
save = flask.Response(json.dumps(js, indent=3))
|
||||||
|
save.headers.set('Content-Disposition', 'attachment', filename='%s.json' % path.basename(vars.savedir))
|
||||||
|
return(save)
|
||||||
|
|
||||||
#============================ METHODS =============================#
|
#============================ METHODS =============================#
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue