當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。