Start the application under the code profiler

def profile(length=25):
    """ Start the application under the code profiler """

    from werkzeug.contrib.profiler import ProfilerMiddleware
    app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length])
    app.run()