Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built in routes command #1446

Closed
wants to merge 3 commits into from
Closed

Built in routes command #1446

wants to merge 3 commits into from

Conversation

kissgyorgy
Copy link
Contributor

I don't want to spam the builtin command namespace (anyway, why not? Django have a lot of builtin commands and works pretty well) but this is the first command I always implement when I start using flask, and my collegues were doing this also.
It shows all the endpoints registered for the app. Routes can be ordered by rules, endpoints and methods.
This is a WIP, because I did not wrote tests for it yet and did not tried with 2.6 and 2.7.
I would like to have some feedback on this and I can work out the details.

@untitaker
Copy link
Contributor

anyway, why not? Django have a lot of builtin commands and works pretty well

Django has a lot of stuff that works surprisingly well, but that's a bad argument.

I like the command, but what exactly are you using it for?

@kissgyorgy
Copy link
Contributor Author

  • If you register a bunch of blueprints on the app, it's harder to track down the exact URLs.
  • You don't always know all the routes, e.g. third party blueprints, extensions.
  • When I worked in a team, it was really handy to see what new views the others guys were writing.
  • I subclassed Flask, so I don't need to write app.route() all the time, (e.g. I just can give it a simple html files, and it automatically makes a view), this commands still shows everything.
  • Django and Pyramid have an overview of the routes in a central place (ursl.py and configurator) which I think is nice.

@mattupstate
Copy link
Contributor

print(app.url_map)

😼

@wshayes
Copy link

wshayes commented Sep 9, 2015

+1 I agree - one of the first things I add as well - just nice to get an overview since the routes are spread all over

…e app.

Orderable by rules, endpoints and methods. Shows up in the builtin command list.
@kissgyorgy
Copy link
Contributor Author

I rebased it to master

@kissgyorgy kissgyorgy changed the title [WIP] Built in routes command Built in routes command Jun 25, 2016
@jirikuncar
Copy link
Contributor

jirikuncar commented Jun 25, 2016

What about creating a package (e.g. Flask-Routes) that would register such command and you can just add an requirement to your project?

    entry_points={
        'flask.commands': [
            'routes = flask_routes:routes',
        ],
    },

@kissgyorgy
Copy link
Contributor Author

kissgyorgy commented Jun 25, 2016

What about creating a package (e.g. Flask-Routes) that would register such command and you can just add an requirement to your project?

You would rather "left-paddify" this simple command? I think that's a bad idea to make such a simple thing a dependency rather than include it as a command. To quote Rob Pike: "A little copying is better than a little dependency."

@davidism
Copy link
Member

Thanks for starting this. I liked the general idea but decided to rework it in #2259.

@davidism davidism closed this Apr 26, 2017
@kissgyorgy kissgyorgy deleted the routes-command branch September 30, 2017 15:05
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants