flask_jsondash: ValueError: urls must start with a leading slash
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
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 4
- Comments: 25 (7 by maintainers)
Commits related to this issue
- Remove static url configuration that improperly sets url path to a file path, resulting in a 500 error in Windows. Closes #128. — committed to christabor/flask_jsondash by christabor 5 years ago
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.:
would need to become:
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.
Hi @christabor ,
I run into the same error. It might be an error that arise from the platform, as I am using MS Windows.
I get the same traceback as @Thuruv and find that when I put in a print() before the error it is related to static files. I had a look at chart_builder.py line 50. Here you use static_url_path=STATIC_DIR. This might not trough an exception on UNIX based systems, but on Windows, the path starts with a letter (fx C:.…). The static_url_path should probably just be static_url_path=“/STATIC/” or something. When I correct like that, the error is gone.
Kr
Just did a quick check and all the routes in the example
app.py, exampleendpoints.py, and the core blueprintcharts_builder.pyhave the correct leading slash.