Example #1
0
def create_app():
    """
    flask application initialization skeleton

    :return Flask:
    """
    app_dir_path = os.path.dirname(os.path.realpath(__file__))
    root_path = os.path.abspath(os.path.join(app_dir_path, os.pardir))
    app = Flask(__name__, instance_relative_config=True, root_path=root_path)

    app.config.from_object(os.getenv('APP_SETTINGS', 'app.config.LocalConfig'))

    if os.path.exists(os.path.join(app.instance_path, 'log_config.conf')):
        fileConfig(os.path.join(app.instance_path, 'log_config.conf'),
                   defaults={
                       'logfilename':
                       os.path.join(app.root_path,
                                    app.config.get('LOGFILE_PATH'))
                   },
                   disable_existing_loggers=False)

    with app.app_context():
        from app.api import api
        from app.db import db
        from app.routes import configure_routes

        configure_routes(api)
        api.init_app(app)
        db.init_app(app)

        db.create_all()

    return app
Example #2
0
def test_get():
    app = Flask(__name__)
    configure_routes(app)
    client = app.test_client()
    url = '/fgh'

    response = client.get(url)
    assert response.status_code == 200
Example #3
0
def test_delete():
    app = Flask(__name__)
    configure_routes(app)
    client = app.test_client()
    url = '/nfg'

    response = client.delete(url)
    assert response.status_code == 200
Example #4
0
def create_app(conf=config.Config):
    app = Flask(__name__)
    app.config.from_object(conf)

    db.init_app(app)
    migrate.init_app(app, db)
    login_manager.init_app(app)
    mail.init_app(app)
    admin.init_app(app)
    csrf.init_app(app)
    configure_routes(app)

    return app
Example #5
0
from flask import Flask
from app.routes import configure_routes

app = Flask(__name__)

configure_routes(app)

if __name__ == '__main__':
    app.run()
Example #6
0
from flask import Flask

app = Flask(__name__)

from app import routes

routes.configure_routes(app)
Example #7
0
from flask_migrate import Migrate
from flask_restful import Api

from app import create_app
from app.database import db
from app.resources import after_request
from app.routes import configure_routes

app = create_app(config_pyfile='config.py')
migrate = Migrate(app, db)
api = Api(app)
configure_routes(api)
app.after_request(after_request)
Example #8
0
def prepare_app(api):
    import_models()
    configure_routes(api)
    db.create_all()