setup_app.py 531 Bytes
Newer Older
Nicolas Joyard committed
1 2
# -*- coding: utf-8 -*-

3 4
import os

Nicolas Joyard committed
5 6 7 8 9 10 11 12
from flask import Flask


def setup_app(name):
    # Create app
    app = Flask(name)

    # Load config
13 14 15
    config_obj = os.environ.get('PARLAPI_CONFIG',
                                'parlapi.config.DefaultConfig')
    app.config.from_object(config_obj)
Nicolas Joyard committed
16 17 18 19 20

    # Setup DB
    from .models import db
    db.init_app(app)

21 22 23 24
    # Setup API
    from .api import setup_api
    api = setup_api(app)

Nicolas Joyard committed
25 26
    # Setup routes
    from .routes import setup_routes
27
    setup_routes(app, api)
Nicolas Joyard committed
28 29

    return app