Python flask_wtf.csrf.CSRFProtect() Examples
The following are 5
code examples of flask_wtf.csrf.CSRFProtect().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
flask_wtf.csrf
, or try the search function
.
Example #1
Source File: flaskman.py From activitypub with Mozilla Public License 2.0 | 6 votes |
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)
Example #2
Source File: __init__.py From yet-another-image-bed with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: app_object.py From docassemble with MIT License | 6 votes |
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
Example #4
Source File: server.py From eNMS with GNU General Public License v3.0 | 5 votes |
def register_extensions(self): self.auth = HTTPBasicAuth() self.csrf = CSRFProtect() self.csrf.init_app(self)
Example #5
Source File: __init__.py From Flask-User-starter-app with BSD 2-Clause "Simplified" License | 4 votes |
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