Skip to content

Commit

Permalink
Fix download errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
yat17006 committed Mar 1, 2021
1 parent 3c639af commit 8b25e73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Python/filegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def __init__(self, make_log, make_summary,
self.makeSummary = make_summary
self.makeAnimation = make_animation
# File Name to be used
self.logFileName = "logs\log-{0}.csv".format(str(sessionId))
self.summaryFileName = "summaries\summary-{0}.csv".format(str(sessionId))
self.logFileName = "logs\\log-{0}.csv".format(str(sessionId))
self.summaryFileName = "summaries\\summary-{0}.csv".format(str(sessionId))
# names of the output files
self.logName = log_name
self.summaryName = summary_name
Expand Down
19 changes: 12 additions & 7 deletions pserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,28 @@ def runSimulation(input1):

@app.route('/download/<fileName>') # This is the endpoint that the javascript code will call to run simulation on server
def download(fileName):
return send_file(fileName, as_attachment=True)
if fileName.startswith("log"):
return send_file("logs\\" + fileName, as_attachment=True)
elif fileName.startswith("summary"):
return send_file("summaries\\" + fileName, as_attachment=True)


@app.route('/download2/<statement>')
def download2(statement):
filename = ""
newname = ""
fileName = ""
newName = ""
for i in range(0, len(statement)):
# Search for delimiter.
if(statement[i] == '&'):
# Construct file names...
filename = statement[:i]
newname = statement[i+1:]
fileName = statement[:i]
newName = statement[i+1:]
break
# Things are over.
return send_file(filename, as_attachment=True, attachment_filename=newname)

if fileName.startswith("log"):
return send_file("logs\\" + fileName, as_attachment=True, attachment_filename=newName)
elif fileName.startswith("summary"):
return send_file("summaries\\" + fileName, as_attachment=True, attachment_filename=newName)

@app.route('/')
def index():
Expand Down

0 comments on commit 8b25e73

Please sign in to comment.