def upload_local(uploaded_file, key, **kwargs):
 filename = secure_filename(uploaded_file.filename)
 file_relative_path = ((((('static/media/' + key) + '/') + generate_hash(key)) + '/') + filename)
 file_path = ((app.config['BASE_DIR'] + '/') + file_relative_path)
 dir_path = file_path.rsplit('/', 1)[0]
 try:
  rmtree(dir_path)
 except OSError:
  pass
 if (not os.path.isdir(dir_path)):
  os.makedirs(dir_path)
 uploaded_file.save(file_path)
 return ('/serve_' + file_relative_path)

def upload_local ( uploaded_file , key , ** kwargs ) : filename = secure_filename ( uploaded_file . filename ) file_relative_path = ( ( ( ( ( 'static/media/' + key ) + '/' ) + generate_hash ( key ) ) + '/' ) + filename ) file_path = ( ( app . config [ 'BASE_DIR' ] + '/' ) + file_relative_path ) dir_path = file_path . rsplit ( '/' , 1 ) [ 0 ] try : rmtree ( dir_path ) except OSError : pass if ( not os . path . isdir ( dir_path ) ) : os . makedirs ( dir_path ) uploaded_file . save ( file_path ) return ( '/serve_' + file_relative_path )
uploads file locally .