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__)
|
2019-08-03 18:55:38 +02:00
|
|
|
app.config.from_object(config_by_name[env or "test"])
|
|
|
|
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)
|
|
|
|
|
2019-08-03 18:55:38 +02:00
|
|
|
@app.route("/health")
|
2019-05-18 17:22:18 +02:00
|
|
|
def health():
|
2019-08-03 18:55:38 +02:00
|
|
|
return jsonify("healthy")
|
|
|
|
|
2019-05-18 17:22:18 +02:00
|
|
|
return app
|