def create_app(config_name=None, celery=None, **kwargs): app = Flask(__name__, **kwargs) env = app.env app.config.from_object(CONFIG_NAME[env]) if "FLASK_CONFIG" in os.environ: app.config.from_envvar("FLASK_CONFIG") print(app.config) sqreen_token = os.getenv("SQREEN_TOKEN") if sqreen_token and not "SQREEN_TOKEN" in app.config: app.config["SQREEN_TOKEN"] = sqreen_token logging.config.dictConfig(app.config["LOGGING_CONFIG"]) if celery: init_celery(celery, app) from sqreened_app.views import hooks_bp app.register_blueprint(hooks_bp) sqreen.start() return app
def create_app(test_config=None): """ :param test_config: Config for the application :return: Instance of the flask app. """ sqreen.start() app = Flask(__name__, instance_relative_config=True) if test_config is None: # load the instance config, if it exists, when not testing app.config.from_pyfile('config.py', silent=True) else: # load the test config if passed in app.config.from_mapping(test_config) # ensure the instance folder exists try: os.makedirs(app.instance_path) except OSError: pass @app.after_request def apply_caching(response): """ :param response: Incoming HTTP response for any of our incoming views/controllers :return: HTTP response with required headers added, for security. """ for headers in SECURITY_HEADERS: header = headers['header'] value = headers['value'] response.headers[header] = value return response # Registering V1 for our APIs. register_blueprints(app) set_debugging(app) return app
from forms import ContactForm from sendgrid.helpers.mail import * from dbhelper import DBHelper from werkzeug.utils import secure_filename response_object = {'status': 'success'} from waitress import serve from flask_sslify import SSLify from flask_caching import Cache cache = Cache() import sqreen from dateutil.parser import parse from datetime import datetime, timezone from flask import Session par = config.config sqreen.start() app = Flask(__name__, static_folder="./dist/static", template_folder="./dist") cache_servers = os.environ.get('MEMCACHIER_SERVERS', par['MEMCACHIER_SERVERS']) cache_servers = None if cache_servers == None: cache.init_app(app, config={'CACHE_TYPE': 'simple'}) else: cache_user = os.environ.get( 'MEMCACHIER_USERNAME') or par['MEMCACHIER_USERNAME'] cache_pass = os.environ.get( 'MEMCACHIER_PASSWORD') or par['MEMCACHIER_PASSWORD'] cache.init_app( app, config={
# # https://www.sqreen.io/terms.html # """ Module called when sitecustomize is automatically imported by python """ import imp import os.path import sys from sqreen import start LOADING = True # Try to import other sitecustomize files in the path current_directory = os.path.dirname(__file__) # Remove ourselves from sys.path avoiding an import loop if current_directory in sys.path: sys.path.remove(current_directory) try: (file, pathname, description) = imp.find_module("sitecustomize", sys.path) except ImportError: # There can no other sitecustomize pass else: imp.load_module("sitecustomize", file, pathname, description) start()