Flask-Dropbox

Add support of Dropbox API to the Flask applications.
Download

Flask-Dropbox Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Igor Davydenko
  • Publisher web site:
  • http://github.com/playpauseandstop/

Flask-Dropbox Tags


Flask-Dropbox Description

Flask-Dropbox is a Flask extension that adds support of Dropbox API to the Flask applications.Installationpip install Flask-DropboxConfigurationSECRET_KEYREQUIRED. As token would be stored in Flask's session instance, you need to configure secret key for your application.DROPBOX_KEYREQUIRED. App key from Dropbox developer site.DROPBOX_SECRETREQUIRED. Secret key from Dropbox developer site.DROPBOX_ACCESS_TYPEREQUIRED. Should be 'dropbox' or 'app_folder' as configured for your app.DROPBOX_CALLBACK_URLBy default, you don't need to provide this setting, cause Flask-Dropbox will setup callback URL automaticly usign current host and type of request, but if you don't trust us, you could to rewrite this setting manually.DROPBOX_CALLBACK_TEMPLATETemplate to be used for showing errors while trying to process oAuth callback from Dropbox API. By default: 'dropbox/callback.html'.Next boolean vars could be sent to the template:- error_oauth_token - Dropbox API didn't return oAuth token.- error_not_equal_tokens - oAuth token from Dropbox API is not equal to request token stored in Flask session.- error_response - Dropbox API returns ErrorResponse instance. Also actual exception as error var would be sent to the template too.DROPBOX_LOGIN_REDIRECTPage to redirect to after user successfully logged in with Dropbox account. By default: /.DROPBOX_LOGOUT_REDIRECTPage to redirect to after user logged out from authenticated Dropbox session. By default: /.Usageapp.py:from flask import Flaskfrom flask.ext.dropbox import Dropbox, DropboxBlueprintimport settingsapp = Flask(__name__)app.config.from_object(settings)dropbox = Dropbox(app)dropbox_blueprint = DropboxBlueprint(dropbox)app.register_blueprint(dropbox_blueprint, url_prefix='/dropbox')settings.py:SECRET_KEY = 'some-secret-key'DROPBOX_KEY = 'dropbox-app-key'DROPBOX_SECRET = 'dropbox-app-secret'DROPBOX_ACCESS_TYPE = 'app_folder'views.py:from flask import url_forfrom werkzeug import secure_filenamefrom app import app, dropbox@app.route('/')def home(): return u'Click here to login with Dropbox.' % \ dropbox.login_url@app.route('/success/')def success(filename): return u'File successfully uploaded as /%s' % filename@app.route('/upload', methods=('GET', 'POST'))def upload(): if not dropbox.is_authenticated: return redirect(url_for('home')) if request.method == 'POST': file_obj = request.files if file_obj: client = dropbox.client filename = secure_filename(file.filename) # Actual uploading process result = client.put_file('/' + filename, file_obj.read()) path = result.lstrip('/') return redirect(url_for('success', filename=path)) return u'< form action="" method="post" >' \ u'< input name="file" type="file" >' \ u'< input type="submit" value="Upload" >' \ u'< /form >'Bugs, feature requests?If you found some bug in Flask-Dropbox library, please, add new issue to the project's GitHub issues.Product's homepage


Flask-Dropbox Related Software