Last active
December 18, 2015 20:29
-
-
Save iandexter/5840397 to your computer and use it in GitHub Desktop.
List available routes, and the respective "help text" from the endpoints.
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 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