Download button manager
flask_download_btn.DownloadBtnManager
class flask_download_btn.DownloadBtnManager(app=None, **kwargs) [source]
The manager has two responsibilities:
- Register download button classes.
- Register routes used by the download button.
Parameters: | app : flask.app.Flask or None, default=None
Flask application with which download buttons are associated. **kwargs :You can set the download button manager's attributes by passing them as keyword arguments. |
---|---|
Attributes: | db : flask_sqlalchemy.SQLAlchemy or None, default=None
SQLAlchemy database associated with the Flask app. btn_template : str, default='download_btn/button.html'Path to the default button template. progress_template : str, default='download_btn/progress.html'Path to the default progress bar template. |
Notes
If app
and db
are not set on initialization, they must be set using
the init_app
method before the app is run.
Examples
from flask import Flask
from flask_download_btn import DownloadBtnManager
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
download_btn_manager = DownloadBtnManager(app, db)
Methods
register(cls, btn_cls) [source]
Decorator for updating the download button class registry.
Parameters: | btn_cls : class
Class of the registered button. |
---|---|
Returns: | btn_cls :
|
Examples
from flask_download_btn import DownloadBtnMixin
@DownloadBtnManager.register
class DownloadBtn(DownloadBtnMixin, db.Model):
...
init_app(self, app, **kwargs) [source]
Initialize the download button manager with the application.
Parameters: | app : flask.app.Flask
Application with which the download button manager is associated. **kwargs :You can set the download button manager's attributes by passing them as keyword arguments. |
---|