2019-12-18 19:02:17 +00:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
import connexion
|
2019-12-19 16:58:51 +00:00
|
|
|
from flask_cors import CORS
|
2019-12-18 19:02:17 +00:00
|
|
|
from flask_marshmallow import Marshmallow
|
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
from flask_migrate import Migrate
|
|
|
|
|
2019-12-18 19:16:26 +00:00
|
|
|
|
2019-12-18 19:02:17 +00:00
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
|
|
connexion_app = connexion.FlaskApp(__name__)
|
|
|
|
|
|
|
|
app = connexion_app.app
|
|
|
|
app.config.from_object('config.default')
|
|
|
|
#app.config.from_pyfile('config.py')
|
|
|
|
if "TESTING" in os.environ and os.environ["TESTING"] == "true":
|
|
|
|
app.config.from_object('config.testing')
|
|
|
|
app.config.from_pyfile('testing.py')
|
|
|
|
|
|
|
|
|
|
|
|
db = SQLAlchemy(app)
|
2020-01-21 20:21:33 +00:00
|
|
|
""":type: sqlalchemy.orm.SQLAlchemy"""
|
2020-01-14 16:45:12 +00:00
|
|
|
|
|
|
|
session = db.session
|
2020-01-21 20:21:33 +00:00
|
|
|
""":type: sqlalchemy.orm.Session"""
|
2020-01-14 16:45:12 +00:00
|
|
|
|
2019-12-18 19:02:17 +00:00
|
|
|
migrate = Migrate(app, db)
|
|
|
|
ma = Marshmallow(app)
|
|
|
|
|
|
|
|
from crc import models
|
2020-01-14 20:26:39 +00:00
|
|
|
from crc import api
|
2019-12-18 19:02:17 +00:00
|
|
|
|
|
|
|
connexion_app.add_api('api.yml')
|
2019-12-19 16:58:51 +00:00
|
|
|
cors = CORS(connexion_app.app)
|
2019-12-18 19:02:17 +00:00
|
|
|
|
|
|
|
@app.cli.command()
|
|
|
|
def load_example_data():
|
|
|
|
"""Load example data into the database."""
|
2019-12-18 19:16:26 +00:00
|
|
|
from example_data import ExampleDataLoader
|
2019-12-30 18:03:57 +00:00
|
|
|
ExampleDataLoader.clean_db()
|
2019-12-18 19:16:26 +00:00
|
|
|
ExampleDataLoader().load_all()
|