Skip to content

Instantly share code, notes, and snippets.

@hunt3ri
Created October 31, 2016 11:26
Show Gist options
  • Save hunt3ri/ff7812e14d183d62b2368d4dc7e4c6aa to your computer and use it in GitHub Desktop.
Save hunt3ri/ff7812e14d183d62b2368d4dc7e4c6aa to your computer and use it in GitHub Desktop.
Add profiling to Python Flask app
@manager.command
def profile(length=500, profile_dir=None):
"""Start the application under the code profiler."""
from werkzeug.contrib.profiler import ProfilerMiddleware
application.wsgi_app = ProfilerMiddleware(application.wsgi_app, restrictions=[length], profile_dir=profile_dir,
sort_by=('time', 'calls'))
application.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment