question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: urls must start with a leading slash

See original GitHub issue

I know somewhere I made a mistake but downloading and running it plainly gave me this error. I can understand somewhere in the routing the error is but I can find it, Can you help?

Traceback (most recent call last): File "app.py", line 17, in <module> app.register_blueprint(charts) File "C:\Users\c_thv\AppData\Local\Continuum\Anaconda2\envs\coffeemug\lib\site-packages\flask\app.py", line 64, in wrapper_func return f(self, *args, **kwargs) File "C:\Users\c_thv\AppData\Local\Continuum\Anaconda2\envs\coffeemug\lib\site-packages\flask\app.py", line 951, in register_blueprint blueprint.register(self, options, first_registration) File "C:\Users\c_thv\AppData\Local\Continuum\Anaconda2\envs\coffeemug\lib\site-packages\flask\blueprints.py", line 151, in register endpoint='static') File "C:\Users\c_thv\AppData\Local\Continuum\Anaconda2\envs\coffeemug\lib\site-packages\flask\blueprints.py", line 76, in add_url_rule view_func, defaults=defaults, **options) File "C:\Users\c_thv\AppData\Local\Continuum\Anaconda2\envs\coffeemug\lib\site-packages\flask\app.py", line 64, in wrapper_func return f(self, *args, **kwargs) File "C:\Users\c_thv\AppData\Local\Continuum\Anaconda2\envs\coffeemug\lib\site-packages\flask\app.py", line 1043, in add_url_rule rule = self.url_rule_class(rule, methods=methods, **options) File "C:\Users\c_thv\AppData\Local\Continuum\Anaconda2\envs\coffeemug\lib\site-packages\werkzeug\routing.py", line 603, in __init__ raise ValueError('urls must start with a leading slash') ValueError: urls must start with a leading slash

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:23 (7 by maintainers)

github_iconTop GitHub Comments

8reactions
christaborcommented, Jun 21, 2017

It looks like there is an invalid url somewhere in your flask app. Are you using the existing example app, or importing it into your own app instance? If the latter, make sure all your url routes have a leading slash, e.g.:

@app.route('foo/bar/')
def foobar():
    pass

would need to become:

@app.route('/foo/bar/')
def foobar():
    pass
1reaction
ShaileshSardacommented, Aug 28, 2020

Hello, I have tried all the possible approaches but still having the same issue. ValueError: urls must start with a leading slash

I am not getting where exactly I need to fix this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix wrong path for flask on windows? - Stack Overflow
Hi updated. there is something to do with app.register_blueprint(charts) when I comment the line -server starts...seems like it sends wrong path ...
Read more >
Unable to run the app after I use 'app.register_blueprint ...
... line 541, in __init__ raise ValueError('urls must start with a leading slash') ValueError: urls must start with a leading slash.
Read more >
Flask 错误记录:ValueError: urls must start with a leading slash
启动flask时报错: ValueError: urls must start with a leading slash 错误代码: bp = Blueprint('cms',__name__,subdomain='cms', from flask import Flask app = ...
Read more >
The Flask Mega-Tutorial, Part V: User Logins - Miguel Grinberg
As in previous chapters, we start by configuring the Flask extensions ... in init raise ValueError('urls must start with a leading slash') ...
Read more >
URL Routing — Werkzeug Documentation (2.2.x)
Rules that end with a slash are “branches”, others are “leaves”. If strict_slashes is enabled (the default), visiting a branch URL without a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found