Beispiel #1
0
def create_app(settings_folder):
    # App
    app = Flask(__name__)
    app.config.from_pyfile(
        os.path.join('..', 'settings', 'common.py'), silent=False)
        # os.path.join(settings_folder, 'common.py'), silent=False)
    app.config.from_pyfile(
        os.path.join(settings_folder, 'local_settings.py'), silent=False)
    CORS(app, resources={r"*": {"origins": "*"}})

    # DB
    db.init_app(app)

    # Signer/Verifier
    sv.config(pub_key_path=os.path.join(settings_folder, 'keypub'))

    # API
    api.init_app(app)
    app.register_blueprint(apidoc.apidoc)
    api.app = app

    # Mail
    api.mail = Mail(app)

    api.urltoken = URLSafeTimedSerializer(app.config['SECRET_KEY'])

    return app
Beispiel #2
0
def create_app(settings_folder):
    # App
    app = Flask(__name__)
    app.config.from_pyfile(os.path.join("..", "settings", "common.py"), silent=False)
    # os.path.join(settings_folder, 'common.py'), silent=False)
    app.config.from_pyfile(os.path.join(settings_folder, "local_settings.py"), silent=False)
    CORS(app, resources={r"*": {"origins": "*"}})

    # DB
    db.init_app(app)

    # Signer/Verifier
    sv.config(pub_key_path=os.path.join(settings_folder, "keypub"))

    # API
    api.init_app(app)
    app.register_blueprint(apidoc.apidoc)
    api.app = app

    # Mail
    api.mail = Mail(app)

    api.urltoken = URLSafeTimedSerializer(app.config["SECRET_KEY"])

    return app
Beispiel #3
0
def create_app(settings_folder):
    # App
    app = Flask(__name__)
    app.config.from_pyfile(
        os.path.join('..', 'settings', 'common.py'), silent=False)
        # os.path.join(settings_folder, 'common.py'), silent=False)
    app.config.from_pyfile(
        os.path.join(settings_folder, 'local_settings.py'), silent=False)
    CORS(app, resources={r"*": {"origins": "*"}})

    # DB
    db.init_app(app)

    # Signer/Verifier
    sv.config(priv_key_path=os.path.join(settings_folder, 'key'),
              priv_key_password=app.config['PRIVATE_KEY_PASSWORD'])

    # API
    api.init_app(app)
    app.register_blueprint(apidoc.apidoc)
    api.app = app

    # Social
    init_social_models(app)

    # Mail
    api.mail = Mail(app)

    return app
Beispiel #4
0
def create_app(settings_folder):
    # App
    app = Flask(__name__)
    app.config.from_pyfile(os.path.join('..', 'settings', 'common.py'),
                           silent=False)
    # os.path.join(settings_folder, 'common.py'), silent=False)
    app.config.from_pyfile(os.path.join(settings_folder, 'local_settings.py'),
                           silent=False)
    CORS(app, resources={r"*": {"origins": "*"}})

    # DB
    db.init_app(app)

    # Signer/Verifier
    sv.config(priv_key_path=os.path.join(settings_folder, 'key'),
              priv_key_password=app.config['PRIVATE_KEY_PASSWORD'])

    # API
    api.init_app(app)
    app.register_blueprint(apidoc.apidoc)
    api.app = app

    # Social
    init_social_models(app)

    # Mail
    api.mail = Mail(app)

    return app
Beispiel #5
0
def create_app(settings_folder):
    # App
    app = Flask(__name__)
    app.config.from_pyfile('../settings/common.py', silent=False)
    app.config.from_pyfile(os.path.join(settings_folder, 'local_settings.py'),
                           silent=False)
    configure_logging(app)
    CORS(app, resources={r"*": {"origins": "*"}})

    # DB
    db.init_app(app)

    # Signer/Verifier
    sv.config(pub_key_path=os.path.join(settings_folder, 'keypub'))

    # Browser
    browser = ESicLivre()
    browser.config(
        firefox=app.config['FIREFOX_PATH'],
        email=app.config['ESIC_EMAIL'],
        senha=app.config['ESIC_PASSWORD'],
        pasta=app.config['DOWNLOADS_PATH'],
        logger=app.logger,
        app=app,
    )
    app.browser = browser

    # API
    api.init_app(app)
    app.register_blueprint(apidoc.apidoc)
    api.browser = browser

    # TODO: colocar isso em um lugar descente...
    @app.route('/static/<path:path>')
    def send_templates(path):
        return send_from_directory('static/', path)

    @app.route('/captcha')
    def send_captcha():
        return send_file('static/captcha.jpg')

    return app
Beispiel #6
0
def create_app():
    # App
    app = Flask(__name__)
    app.config.from_pyfile('../settings/common.py', silent=False)
    app.config.from_pyfile('../settings/local_settings.py', silent=False)
    configure_logging(app)
    CORS(app, resources={r"*": {"origins": "*"}})

    # DB
    db.init_app(app)

    # Signer/Verifier
    sv.config(pub_key_path="settings/keypub")

    # Browser
    browser = ESicLivre()
    browser.config(
        firefox=app.config['FIREFOX_PATH'],
        email=app.config['ESIC_EMAIL'],
        senha=app.config['ESIC_PASSWORD'],
        pasta=app.config['DOWNLOADS_PATH'],
        logger=app.logger,
        app=app,
        )
    app.browser = browser

    # API
    api.init_app(app)
    app.register_blueprint(apidoc.apidoc)
    api.browser = browser

    # TODO: colocar isso em um lugar descente...
    @app.route('/static/<path:path>')
    def send_templates(path):
        return send_from_directory('static/', path)

    @app.route('/captcha')
    def send_captcha():
        return send_file('static/captcha.jpg')

    return app