2019-05-18 17:22:18 +02:00
|
|
|
from flask import Flask, jsonify
|
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
2019-05-18 19:00:13 +02:00
|
|
|
from flask_restplus import Api
|
2019-05-18 17:22:18 +02:00
|
|
|
|
|
|
|
db = SQLAlchemy()
|
|
|
|
|
|
|
|
|
|
|
|
def create_app(env=None):
|
2019-05-18 19:00:13 +02:00
|
|
|
from app.config import config_by_name
|
|
|
|
from app.routes import register_routes
|
|
|
|
|
2019-05-18 17:22:18 +02:00
|
|
|
app = Flask(__name__)
|
|
|
|
app.config.from_object(config_by_name[env or 'test'])
|
2019-05-18 19:00:13 +02:00
|
|
|
api = Api(app, title='Flaskerific API', version='0.1.0')
|
2019-05-18 17:22:18 +02:00
|
|
|
|
2019-05-18 19:00:13 +02:00
|
|
|
register_routes(api, app)
|
2019-05-18 17:22:18 +02:00
|
|
|
db.init_app(app)
|
|
|
|
|
|
|
|
@app.route('/health')
|
|
|
|
def health():
|
|
|
|
return jsonify('healthy')
|
|
|
|
return app
|