2017-05-29 161 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