cr-connect-workflow/crc/__init__.py

50 lines
1.2 KiB
Python
Raw Normal View History

import logging
import os
import connexion
from flask_cors import CORS
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_sso import SSO
logging.basicConfig(level=logging.INFO)
connexion_app = connexion.FlaskApp(__name__)
app = connexion_app.app
app.config.from_object('config.default')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
if "TESTING" in os.environ and os.environ["TESTING"] == "true":
app.config.from_object('config.testing')
2020-02-28 16:33:08 +00:00
app.config.from_pyfile('../config/testing.py')
else:
2020-02-06 19:36:02 +00:00
app.config.root_path = app.instance_path
app.config.from_pyfile('config.py', silent=True)
print(app.config)
db = SQLAlchemy(app)
2020-01-21 20:21:33 +00:00
""":type: sqlalchemy.orm.SQLAlchemy"""
session = db.session
2020-01-21 20:21:33 +00:00
""":type: sqlalchemy.orm.Session"""
migrate = Migrate(app, db)
ma = Marshmallow(app)
sso = SSO(app=app)
from crc import models
from crc import api
connexion_app.add_api('api.yml')
cors = CORS(connexion_app.app)
@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()