Example #1
0
def app():
    app = Flask(__name__)
    app.debug = True
    api = Api(app)

    class Hello(Resource):
        def get(self):
            return "hello"

        def get_error(self):
            raise ValueError("error")

    api.add_resource(Hello)
    app.resource = Hello
    app.api = api
    return app
def app():
    app = Flask(__name__)
    app.debug = True
    api = Api(app)

    class Hello(Resource):
        def get(self):
            return "hello"

        def get_error(self):
            raise ValueError("error")

        def post_login(self):
            return "login"

    api.add_resource(Hello)
    # name can't be unicode on py2
    api.add_resource(Hello, name=str("hi"))

    app.resource = Hello
    app.api = api
    return app