2017-05-29 162 views
0

在windows 10 安装烧瓶jsonDash当启动应用程序接收到该错误:如何修复烧瓶在Windows上的错误路径?

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) 

我这里使用的代码形式https://github.com/christabor/flask_jsondash

似乎像patth differance linux和windows一样的问题。如何解决它?预先感谢您非常

一些额外的info.form调试器: enter image description here

+0

当您使用'app.route'定义路线图时,必定会错过一个主要的斜线。 – stamaimer

+0

如何解决它?我非常非常新... – Serhiy

回答

0

当你定义的URL,确保它与'/'

@app.route('/landing-page', methods=['GET', 'POST']) 
def landing_page(): 
    return "Landing Page" 

开始如果你建造的路线不一样/@app.route('landing-page')那么错误。

+0

已更新。你可以看看应用程序。其实它是从回购的锥体。 – Serhiy

+0

我可以看到'访问图表蓝图.' –

+0

是有错误拍摄 – Serhiy