#NEWLINE# def upload( ) : #NEWLINE# #INDENT# '\n    Upload file to Dropbox.\n\n    If user not logged in - redirects to "Home" page.\n    ' #NEWLINE# if ( not dropbox . is_authenticated ) : #NEWLINE# #INDENT# return redirect ( url_for ( 'home' ) ) #NEWLINE# #UNINDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# file_obj = request . files [ 'file' ] #NEWLINE# if file_obj : #NEWLINE# #INDENT# client = dropbox . client #NEWLINE# filename = secure_filename ( file_obj . filename ) #NEWLINE# result = client . put_file ( ( '/' + filename ) , file_obj . read ( ) ) #NEWLINE# path = result [ 'path' ] . lstrip ( '/' ) #NEWLINE# return redirect ( url_for ( 'success' , filename = path ) ) #NEWLINE# #UNINDENT# #UNINDENT# return render_template ( 'upload.html' )