Skip to content

Instantly share code, notes, and snippets.

@ties
Last active August 29, 2015 14:27
Show Gist options
  • Save ties/2f9709d1abb011318701 to your computer and use it in GitHub Desktop.
Save ties/2f9709d1abb011318701 to your computer and use it in GitHub Desktop.
from flask.views import MethodView
from flask import jsonify
class JSONMethodView(MethodView):
"""
A view that returns json objects
The view calls self.dispatch_[method] and
returns the result using jsonify
"""
def dispatch_request(self, *args, **kwargs):
res = super(JSONMethodView, self).dispatch_request(*args, **kwargs)
return jsonify(res)
"""
Map the routes
"""
blueprint.add_url_rule("/aggregate/<group>",
view_func=JobfeedAggregation.as_view('data_endpoint'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment