本文整理汇总了Python中flask_uploads.UploadSet方法的典型用法代码示例。如果您正苦于以下问题:Python flask_uploads.UploadSet方法的具体用法?Python flask_uploads.UploadSet怎么用?Python flask_uploads.UploadSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_uploads
的用法示例。
在下文中一共展示了flask_uploads.UploadSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_app
# 需要导入模块: import flask_uploads [as 别名]
# 或者: from flask_uploads import UploadSet [as 别名]
def create_app(config_name):
app = Flask(__name__)
# Creating the app configurations
app.config.from_object(config_options[config_name])
config_options[config_name].init_app(app)
# Initializing flask extensions
bootstrap.init_app(app)
db.init_app(app)
login_manager.init_app(app)
mail.init_app(app)
simple.init_app(app)
# Registering the blueprint
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint,url_prefix = '/auth')
# setting config
from .requests import configure_request
configure_request(app)
# configure UploadSet
configure_uploads(app,photos)
return app
示例2: setup_components
# 需要导入模块: import flask_uploads [as 别名]
# 或者: from flask_uploads import UploadSet [as 别名]
def setup_components(app):
# bootstrap
Bootstrap(app)
# sqlalchemy
models.db.init_app(app)
# security
user_datastore = SQLAlchemyUserDatastore(models.db, models.User,
models.Role)
security = Security(app, user_datastore)
# admin
ModelView.page_size = app.config.get('SLIM_ITEMS_PER_PAGE', 5)
admin.name = app.config.get('SLIM_APPNAME', 'SLiM')
admin.init_app(app)
# define a context processor for merging flask-admin's template context
# into the flask-security views.
@security.context_processor
def security_context_processor():
return dict(
admin_base_template=admin.base_template,
admin_view=admin.index_view,
h=admin_helpers,
get_url=url_for
)
# nav
nav.init_app(app)
# flask-uploads
# patch_request_class(app, app.config['MAX_CONTENT_LENGTH'])
request_uploader = UploadSet('requests',
app.config['SLIM_REQUEST_EXTENSIONS'])
configure_uploads(app, request_uploader)
# components
components = dict(
user_datastore=user_datastore,
security=security,
request_uploader=request_uploader,
)
return components