Skip to content

Instantly share code, notes, and snippets.

@iandexter
Last active December 18, 2015 20:29
Show Gist options
  • Save iandexter/5840397 to your computer and use it in GitHub Desktop.
Save iandexter/5840397 to your computer and use it in GitHub Desktop.
List available routes, and the respective "help text" from the endpoints.
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/api', methods = ['GET'])
def this_func():
"""This is a function. It does nothing."""
return jsonify({ 'result': '' })
@app.route('/api/help', methods = ['GET'])
"""Print available functions."""
func_list = {}
for rule in app.url_map.iter_rule():
if rule.endpoint != 'static':
func_list[rule.rule] = app.view_functions[rule.endpoint].__doc__
return jsonify(func_list)
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment