Reputation: 1981
installed flask jsonDash on windows 10. When starting app receiving this error:
Traceback (most recent call last):
File "D:/WORK/mc-metrics/mc_app/app.py", line 17, in <module>
app.register_blueprint(charts)
File "C:\Python35\lib\site-packages\flask\app.py", line 64, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Python35\lib\site-packages\flask\app.py", line 951, in register_blueprint
blueprint.register(self, options, first_registration)
File "C:\Python35\lib\site-packages\flask\blueprints.py", line 151, in register
endpoint='static')
File "C:\Python35\lib\site-packages\flask\blueprints.py", line 76, in add_url_rule
view_func, defaults=defaults, **options)
File "C:\Python35\lib\site-packages\flask\app.py", line 64, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Python35\lib\site-packages\flask\app.py", line 1043, in add_url_rule
rule = self.url_rule_class(rule, methods=methods, **options)
File "C:\Python35\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
app.py
"""This is an example app, demonstrating usage."""
import os
from flask import Flask
from flask_jsondash.charts_builder import charts
app = Flask(__name__)
app.config['SECRET_KEY'] = 'NOTSECURELOL'
app.config.update(
JSONDASH_FILTERUSERS=False,
JSONDASH_GLOBALDASH=True,
JSONDASH_GLOBAL_USER='global',
)
app.debug = True
app.register_blueprint(charts) //when I comment it it starts server
def _can_edit_global():
return True
def _can_delete():
return True
def _can_clone():
return True
def _get_username():
return 'anonymous'
# Config examples.
app.config['JSONDASH'] = dict(
metadata=dict(
created_by=_get_username,
username=_get_username,
),
static=dict(
js_path='js/vendor/',
css_path='css/vendor/',
),
auth=dict(
edit_global=_can_edit_global,
clone=_can_clone,
delete=_can_delete,
)
)
@app.route('/', methods=['GET'])
def index():
"""Sample index."""
return '<a href="/charts">Visit the charts blueprint.</a>'
if __name__ == '__main__':
PORT = int(os.getenv('PORT', 8080))
HOST = os.getenv('HOST', '0.0.0.0')
app.run(debug=True, host=HOST, port=PORT)
I used code form here https://github.com/christabor/flask_jsondash
Seems like issue with patth differance linux and windows. How to solve it? Thank you very much in advance
Some extra info.form debugger:
Upvotes: 0
Views: 8725
Reputation: 10315
When you define the url make sure it's start with '/'
@app.route('/landing-page', methods=['GET', 'POST'])
def landing_page():
return "Landing Page"
If I construct the route without /
like @app.route('landing-page')
then the error.
Upvotes: 1