def create_app(config_object=configs.ProdConfig): app = connexion.App(__name__) app.add_api("openapi.yml", resolver=RestyResolver("api"), strict_validation=True) app.app.config.from_object(config_object) db.init_app(app.app) app.app.app_context().push() db.create_all() return app
def create_app(): app = Flask(__name__) app.config.from_pyfile("config.py") marshmallow.init_app(app) db.init_app(app) with app.app_context(): db.create_all() initialize_error_handler(app) initialize_blueprints(app) return app
def db(app): """A database for the tests.""" _db.app = app with app.app_context(): _db.create_all() setup_initial_data(_db) yield _db # Explicitly close DB connection _db.session.close() _db.drop_all()
__author__ = 'linas' from orm import db, WindPoint db.create_all() w1 = WindPoint(service="test", strenght_knts=15, direction='N') db.session.add(w1) db.session.commit()
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False app.config["SESSION_TYPE"] = "redis" app.config["SESSION_REDIS"] = Redis(host=REDIS_HOST, db=0) app.config["PERMANENT_SESSION_LIFETIME"] = timedelta(hours=24) if INSECURE_CORS: CORS(app, supports_credentials=True) else: app.config["SESSION_COOKIE_SECURE"] = True CORS(app, resources={r"/*": {"origins": FRONTEND_URL}}) # init db db.init_app(app) with app.app_context(): db.create_all() # redis session Session(app) # all error pages are now JSON instead of HTML @app.errorhandler(HTTPException) def handle_exception(e): response = e.get_response() response.data = dumps( APIResponse(code=e.code, name=e.name, description=e.description, response={}).__dict__)