Skip to content

flask routes crashes if there is no route available #2751

Closed
@timothyqiu

Description

@timothyqiu

Flask has a route for static files by default, and I disabled that by setting static_folder to None.

from flask import Flask

app = Flask(__name__, static_folder=None)

Expected Behavior

With the code above, I expect the output of flask routes to be like this:

Endpoint  Methods  Rule
--------  -------  -----------------------

or some message saying there is no route available.

Actual Behavior

But it crashed instead:

Traceback (most recent call last):
  File "/Users/timothy/.virtualenvs/sample/bin/flask", line 11, in <module>
    sys.exit(main())
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/flask/cli.py", line 890, in main
    cli.main(args=args, prog_name=name)
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/flask/cli.py", line 557, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/flask/cli.py", line 412, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/timothy/.virtualenvs/sample/lib/python3.6/site-packages/flask/cli.py", line 841, in routes_command
    max(len(rule.endpoint) for rule in rules),
ValueError: max() arg is an empty sequence

Environment

  • Python version: 3.6.3
  • Flask version: 1.0.1
  • Werkzeug version: 0.14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions