This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import abort, make_response, jsonify | |
abort(make_response(jsonify(message="Message goes here"), 400)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Response, jsonify | |
import json | |
from flask_restful import Resource | |
class Api(Resource): | |
def post(self): | |
response = Response( | |
response=json.dumps(dict(error='err')), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""An example of a cache decorator.""" | |
import json | |
from functools import wraps | |
from redis import StrictRedis | |
redis = StrictRedis() | |
def cached(func): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Flask, Python 2.7, Single core 271.97 [#/sec] (mean) | |
Flask, Pypy, Single core 547.11 | |
Flask+Gunicorn, Python, 8Core 1363.06 | |
Flask+Gunicorn, Pypy, 8Core 2701.90 | |
Flask+Gunicorn+Tornado, Python, 8Core 1403.88 | |
Flask+Gunicorn+Tornado, Pypy, 8Core 2582.12 | |
Tornado, Python, Single core 839.65 | |
Tornado, Async, Python, Single core 801.19 | |
Tornado, Pypy, Single core 1841.41 | |
Tornado, Async, Pypy, Single core 1734.37 |
NewerOlder