V
V
Vladimir Abiduev2015-03-13 14:11:08
Flask
Vladimir Abiduev, 2015-03-13 14:11:08

Is there a ready-made module similar to rake stats for Flask?

I wanted to get something like this output

d26e77d55df04e79b3aa4a45c0abfbe3.png

. For url, I used this snippet , but I'm interested in statistics: the number of models, controllers, libraries, and everything like that.

@manager.command
def stat():
    models = db.get_binds()

    methods = set()
    blueprints = set()
    rules_count = 0

    for rule in app.url_map.iter_rules():
        rules_count += 1
        blueprints.update([rule.endpoint.split('.')[0]])
        methods.update(rule.methods)

    print('{0:10} {1:5}\n'.format('Name', 'Count'))
    print('{0:10} {1:5}'.format('Models', len(models)))
    print('{0:10} {1:5}'.format('Methods', len(methods)))
    print('{0:10} {1:5}'.format('Blueprints', len(blueprints)))
    print('{0:10} {1:5}'.format('Rules', rules_count))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question