def client(): model_container = MagicMock(spec=ModelContainer) model_container.predict.return_value = EXPECTED_RESULT['prediction'] api = create_api(model_container) return testing.TestClient(api)
# -*- coding: utf-8 -*- import logging import time import traceback from app.model.order import Order class Engine(object): @staticmethod def run(): while True: try: Order.check_order_process() except Exception as e: logging.error(traceback.format_exc()) db.session.rollback() logging.error('Engine.run error exception: {}'.format(e)) db.session.close() time.sleep(10) if __name__ == '__main__': from app import create_api, db app = create_api() with app.app_context(): Engine.run()
from app import create_api api = create_api()
def api(app, database): """Init SAFRS""" create_api(app)
from flask_migrate import Migrate, MigrateCommand from flask_script import Manager from flask import json from app.main import create_app from app import create_blueprint, create_api from generate_routes import RouteGenerator app = create_app() blueprint = create_blueprint() api = create_api(blueprint) app.register_blueprint(blueprint) app.app_context().push() manager = Manager(app) route_generator = RouteGenerator() @manager.command def run(): app.run() @manager.command def generate_routes(): dump("information.json") route_generator.generate_serverless_route_configs( "route_configs.yml", "unauthorized-endpoints.txt")
def client(): return testing.TestClient(app.create_api())
def app(): app = create_app("unittests") blueprint = create_blueprint(str(uuid.uuid1())) api = create_api(blueprint) app.register_blueprint(blueprint) return app