示例#1
0
def create_test_app(path, func, **options):
    """
    create a test app that wraps a func at the path specified, and
    returns a test client to of the flask app
    """
    app = Flask(__name__)
    route_set = FlaskRouteSet()
    route_set.route_function(path, func)
    route_set.init_app(app)
    return app.test_client()
示例#2
0
def create_test_app(path, func, **options):
    """
    create a test app that wraps a func at the path specified, and
    returns a test client to of the flask app
    """
    app = Flask(__name__)
    app.debug = True
    route_set = FlaskRouteSet()
    route_set.route_function(path, func)
    route_set.init_app(app)
    return app.test_client()
示例#3
0
app = Flask(__name__)
deck = Deck()

route_set = FlaskRouteSet()
route_set.route_object('/deck', deck,
                       # if exceptions are added to error_exceptions,
                       # they will be caught and raise a success: false
                       # response, with the error message being the message
                       # of the exception
                       error_exceptions=[DeckException])


def raise_401():
    raise ApiException("", status_code=401)

route_set.route_function("/raise_401", raise_401)


def raise_404():
    raise NotFoundException()

route_set.route_function("/raise_404", raise_404)

swagger = Swagger("myApi", "1.0")
# route_set.add_extension(swagger)

route_set.init_app(app)
swagger.init_app(app)

app.debug = True
示例#4
0
app = Flask(__name__)
deck = Deck()

route_set = FlaskRouteSet()
route_set.route_object('/deck', deck,
                       # if exceptions are added to error_exceptions,
                       # they will be caught and raise a success: false
                       # response, with the error message being the message
                       # of the exception
                       error_exceptions=[DeckException])


def raise_401():
    raise ApiException("", status_code=401)

route_set.route_function("/raise_401", raise_401)


def raise_404():
    raise NotFoundException()

route_set.route_function("/raise_404", raise_404)

swagger = Swagger("myApi", "1.0")
# route_set.add_extension(swagger)

route_set.init_app(app)
swagger.init_app(app)

app.debug = True