当前位置: 首页>>代码示例>>Python>>正文


Python csrf.CSRFProtect方法代码示例

本文整理汇总了Python中flask_wtf.csrf.CSRFProtect方法的典型用法代码示例。如果您正苦于以下问题:Python csrf.CSRFProtect方法的具体用法?Python csrf.CSRFProtect怎么用?Python csrf.CSRFProtect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_wtf.csrf的用法示例。


在下文中一共展示了csrf.CSRFProtect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from flask_wtf import csrf [as 别名]
# 或者: from flask_wtf.csrf import CSRFProtect [as 别名]
def run(self):
        self.app = Flask(__name__,
                         template_folder=self.get_template_folder(),
                         static_folder=self.get_static_folder())
        self.app.config.update(WTF_CSRF_CHECK_DEFAULT=False)
        self.app.config["CSS"] = self.CSS
        self.app.config.update(self.config)
        self.csrf = CSRFProtect(self.app)
        ## Add routes:
        for path, methods, f, kwargs in app._data.routes:
            ## Add the route:
            self.app.route(path, methods=methods, **kwargs)(wrap_function(self, f))
        ## Add filters:
        for f in app._data.filters:
            ## Add the template filter function:
            self.app.template_filter()(wrap_function(self, f))
        self.app.run(debug=1, port=self.port) 
开发者ID:dsblank,项目名称:activitypub,代码行数:19,代码来源:flaskman.py

示例2: create_app

# 需要导入模块: from flask_wtf import csrf [as 别名]
# 或者: from flask_wtf.csrf import CSRFProtect [as 别名]
def create_app(config_name):
    """Factory of Creating app
    @param:
        config_name - all configurations of app
    """
    sentry_sdk.init(
        dsn="",
        integrations=[FlaskIntegration()])
    application = Flask(__name__)
    application.config.from_object(config[config_name])
    config[config_name].init_app(application)

    csrf = CSRFProtect()

    from .image.model import image_db
    from .image.views import image as image_blueprint
    from .image.apis import blueprint as image_api_blueprint

    csrf.init_app(application)
    image_db.init_app(application)
    application.register_blueprint(image_blueprint)
    application.register_blueprint(image_api_blueprint, url_prefix='/api/v1')

    return application 
开发者ID:leollon,项目名称:yet-another-image-bed,代码行数:26,代码来源:__init__.py

示例3: create_app

# 需要导入模块: from flask_wtf import csrf [as 别名]
# 或者: from flask_wtf.csrf import CSRFProtect [as 别名]
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    from docassemble.base.config import daconfig
    import docassemble.webapp.database
    import docassemble.webapp.db_object
    connect_string = docassemble.webapp.database.connection_string()
    alchemy_connect_string = docassemble.webapp.database.alchemy_connection_string()
    app.config['SQLALCHEMY_DATABASE_URI'] = alchemy_connect_string
    app.secret_key = daconfig.get('secretkey', '38ihfiFehfoU34mcq_4clirglw3g4o87')
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    db = docassemble.webapp.db_object.init_flask()
    db.init_app(app)
    csrf = CSRFProtect()
    csrf.init_app(app)
    babel = Babel()
    babel.init_app(app)
    if daconfig.get('behind https load balancer', False):
        if proxyfix_version >= 15:
            app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
        else:
            app.wsgi_app = ProxyFix(app.wsgi_app)
    if 'cross site domains' in daconfig:
        CORS(app, origins=daconfig['cross site domains'], supports_credentials=True)
    return app, csrf, babel 
开发者ID:jhpyle,项目名称:docassemble,代码行数:27,代码来源:app_object.py

示例4: register_extensions

# 需要导入模块: from flask_wtf import csrf [as 别名]
# 或者: from flask_wtf.csrf import CSRFProtect [as 别名]
def register_extensions(self):
        self.auth = HTTPBasicAuth()
        self.csrf = CSRFProtect()
        self.csrf.init_app(self) 
开发者ID:eNMS-automation,项目名称:eNMS,代码行数:6,代码来源:server.py

示例5: create_app

# 需要导入模块: from flask_wtf import csrf [as 别名]
# 或者: from flask_wtf.csrf import CSRFProtect [as 别名]
def create_app(extra_config_settings={}):
    """Create a Flask application.
    """
    # Instantiate Flask
    app = Flask(__name__)

    # Load common settings
    app.config.from_object('app.settings')
    # Load environment specific settings
    app.config.from_object('app.local_settings')
    # Load extra settings from extra_config_settings param
    app.config.update(extra_config_settings)

    # Setup Flask-SQLAlchemy
    db.init_app(app)

    # Setup Flask-Migrate
    migrate.init_app(app, db)

    # Setup Flask-Mail
    mail.init_app(app)

    # Setup WTForms CSRFProtect
    csrf_protect.init_app(app)

    # Register blueprints
    from .views import register_blueprints
    register_blueprints(app)

    # Define bootstrap_is_hidden_field for flask-bootstrap's bootstrap_wtf.html
    from wtforms.fields import HiddenField

    def is_hidden_field_filter(field):
        return isinstance(field, HiddenField)

    app.jinja_env.globals['bootstrap_is_hidden_field'] = is_hidden_field_filter

    # Setup an error-logger to send emails to app.config.ADMINS
    init_email_error_handler(app)

    # Setup Flask-User to handle user account related forms
    from .models.user_models import User
    from .views.main_views import user_profile_page

    # Setup Flask-User
    user_manager = UserManager(app, db, User)

    @app.context_processor
    def context_processor():
        return dict(user_manager=user_manager)

    return app 
开发者ID:lingthio,项目名称:Flask-User-starter-app,代码行数:54,代码来源:__init__.py


注:本文中的flask_wtf.csrf.CSRFProtect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。