Exemplo n.º 1
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    mail.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    Migrate(app, db)

    if not app.debug and not app.testing and not app.config['SSL_DISABLE']:
        from flask_sslify import SSLify
        sslify = SSLify()
        sslify.init_app(app)

    from .core import core
    from .costs import costs
    from .needs import needs
    from .users import users
    from .groups import groups
    from .api import api

    app.register_blueprint(core)
    app.register_blueprint(costs)
    app.register_blueprint(users)
    app.register_blueprint(needs)
    app.register_blueprint(groups)
    app.register_blueprint(api, url_prefix='/api')

    return app
Exemplo n.º 2
0
class AppFactoryContext(object):

    def __init__(self):
        self.sslify = SSLify()
        self.app = None
        self.appctx = None

    def __enter__(self):
        self.app = self.create_app()
        self.appctx = self.app.app_context()
        self.appctx.push()
        return self.appctx

    def __exit__(self, exc_type, exc_value, exc_tb):
        self.appctx.pop()
        self.app = None
        self.appctx = None

    def create_app(self):
        app = Flask(__name__)
        app.config['DEBUG'] = False
        app.config['TESTING'] = False
        app.config['SERVER_NAME'] = 'example.com'
        app.config['SSLIFY_PERMANENT'] = True
        self.sslify.init_app(app)
        app.add_url_rule('/', 'home', self.view_home)
        return app

    def view_home(self):
        return 'home'
Exemplo n.º 3
0
class AppFactoryContext(object):
    def __init__(self):
        self.sslify = SSLify()
        self.app = None
        self.appctx = None

    def __enter__(self):
        self.app = self.create_app()
        self.appctx = self.app.app_context()
        self.appctx.push()
        return self.appctx

    def __exit__(self, exc_type, exc_value, exc_tb):
        self.appctx.pop()
        self.app = None
        self.appctx = None

    def create_app(self):
        app = Flask(__name__)
        app.config['DEBUG'] = False
        app.config['TESTING'] = False
        app.config['SERVER_NAME'] = 'example.com'
        app.config['SSLIFY_PERMANENT'] = True
        self.sslify.init_app(app)
        app.add_url_rule('/', 'home', self.view_home)
        return app

    def view_home(self):
        return 'home'
Exemplo n.º 4
0
def __configure(_app):
    # app.config
    CONFIG[getenv('ENV', 'production')].init_app(_app)

    # asset files
    manifest_json = path.join(path.dirname(__file__),
                              '../static/manifest.json')
    asset = AssetConfigurator(manifest_json)
    asset.init_app(_app)

    # ssl support
    sslify = SSLify(
        _app,
        subdomains=True,
        skips=[
            # does not need first slash
            '_ah/health'
        ])
    sslify.init_app(_app)
Exemplo n.º 5
0

# a token is unique by its jti
def is_blacklisted(jti):
    return jti in blacklist


# For active chats purpose
active_chats = dict()

# Initializing config data
# Run app
cors.init_app(app)
db.init_app(app)
guard.init_app(app, models.User, is_blacklisted=is_blacklisted)
sslify.init_app(app)

# Usernames must contain only letters (a-z), numbers (0-9), dashes (-), underscores (_)
VALID_USERNAME_CHARS = set(["-", "_"] + [str(i) for i in range(0, 10)] +
                           list(ascii_lowercase))
API_BASE_URL = "/api/v1"


@app.route(API_BASE_URL)
def home():
    return {"Hello": "World"}, 200


#########################################
#               Auth Routes             #
#########################################