Skip to content

Commit

Permalink
avoid overriding in-built file variable in flask example
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantgoel committed Oct 31, 2018
1 parent 9de4030 commit 611d908
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/flask/upload-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
@app.route('/', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
file = FileTarget(os.path.join(tempfile.gettempdir(), "test"))
file_ = FileTarget(os.path.join(tempfile.gettempdir(), "test"))

hdict = {}
for h in request.headers:
hdict[h[0]] = h[1]

parser = StreamingFormDataParser(headers=hdict)

parser.register('file', file)
parser.register('file', file_)

timeA = time.perf_counter()
while True:
Expand All @@ -41,8 +41,10 @@ def upload_file():
break
parser.data_received(chunk)
timeB = time.perf_counter()

print("time spent on file reception: %fs" % (timeB-timeA))
return file.multipart_filename + ": upload done"

return file_.multipart_filename + ": upload done"
return page


Expand Down

0 comments on commit 611d908

Please sign in to comment.