From 550d79910ebe6a46b98e64d7237e086ec14099b2 Mon Sep 17 00:00:00 2001 From: assar Date: Tue, 6 Jun 2017 17:38:01 +0000 Subject: [PATCH] File transfer works --- server.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index c996a09..b68aa2e 100644 --- a/server.py +++ b/server.py @@ -66,8 +66,19 @@ def alter(partID): file = request.files['file'] filename = secure_filename(file.filename) file.save(os.path.join('/srv/datasheets', filename))''' - print dict(request.data) - print dict(request.files) + print 'Form:', request.form + print ' ' + print 'Files:', request.files + if len(request.files) == 0: + print 'No file :(' + else: + print 'Oooh look, a file! :)' + somefile = request.files['datasheet-file'] + print somefile.filename + filename = secure_filename(somefile.filename) + somefile.save('/home/davide/' + filename) + print "Now it's mine" + return '{"status":"ok"}' def connect(user, password, db, host='localhost', port=5432): '''Returns a connection and a metadata object'''