Ejemplo n.º 1
0
from flask import Flask
from flask.ext.marshmallow import Marshmallow

from config import config

ma = Marshmallow()


def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    ma.init_app(app)

    from .api_v1 import api as api_v1_blueprint
    app.register_blueprint(api_v1_blueprint, url_prefix='/api/v1')

    return app
Ejemplo n.º 2
0
            template_folder=settings.TEMPLATE_FOLDER)
app.config['SQLALCHEMY_POOL_RECYCLE'] = 1800
# manager = Manager(app)

# Caching
cache = Cache(config={'CACHE_TYPE': 'simple'})

# Initialize celery
celery = make_celery(app)
from nsweb import tasks

db = SQLAlchemy()
_blueprints = []

# API-related stuff
marshmallow = Marshmallow()

mail = Mail()


def setup_logging(logging_path, level):
    '''Setups logging in app'''
    from logging.handlers import RotatingFileHandler
    from logging import getLogger, getLevelName

    file_handler = RotatingFileHandler(logging_path)
    file_handler.setLevel(getLevelName(level))
    loggers = [app.logger, getLogger('sqlalchemy')]
    for logger in loggers:
        logger.addHandler(file_handler)
Ejemplo n.º 3
0
from flask.ext.marshmallow import Marshmallow  # Data serialization
from sqlalchemy import func, and_

from werkzeug.security import generate_password_hash, check_password_hash

sleep(5)  # Delay is required for allowing the Database to startup

app = Flask(__name__)
app.secret_key = "ASECRETKEYGOESHERE"
app.config[
    'SQLALCHEMY_DATABASE_URI'] = "postgres://*****:*****@db/varda"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['DEBUG'] = True

db = SQLAlchemy(app)
ma = Marshmallow(app)
# csrf = SeaSurf(app)
lm = LoginManager()

from models import *

# CREATE DATABASE
db.create_all()

# INITIALIZE LOGIN MANAGEMENT
lm.init_app(app)


# ROUTES
@app.route('/api/')
def index():