Example #1
0
def create_app(app_name, config):

    app = Flask(app_name)
    app.config.from_object(config)

    app.db = SQLAlchemy(app)

    app.migrate = Migrate(app, app.db)

    app.bcrypt = Bcrypt(app)

    app.api = Api(app, prefix="/api/v1")

    app.api_registry = []

    return app
Example #2
0
from app.api_1_0 import blueprint as api

# configure according which machine we're running
module = __import__("config")
configuration = getattr(module, os.getenv("LOCAL_ENV", "ProductionEnvironment"))

# Basic App initialization     ===============================================

app = Flask(__name__)
app.config.from_object(configuration)

app.appBucket = Bucket("couchbase://" + app.config["CB_HOST"] + "/" + app.config["CB_APP_BUCKET"])
app.userBucket = Bucket("couchbase://" + app.config["CB_HOST"] + "/" + app.config["CB_USERS_BUCKET"])

jwt = JWT(app)
app.bcrypt = Bcrypt(app)

# initialize JWT authentication  ======================================
@jwt.authentication_handler
def authenticate(username, password):
    bucket = app.userBucket
    print "@authentication handler"
    user = []
    try:
        q = N1QLQuery("SELECT * FROM " + app.config["CB_USERS_BUCKET"] + " WHERE username = $user", user=username)
        results = bucket.n1ql_query(q)

        print vars(results)

        resultsCount = 0