如何在Windows上修复烧瓶的错误路径?

时间:2017-05-29 11:15:00

标签: python python-3.x flask

在Windows 10上安装了烧瓶jsonDash。 启动应用程序时收到此错误:

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

1 个答案:

答案 0 :(得分:0)

定义网址时,请确保它以'/'

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

如果我构建的路线没有/ @app.route('landing-page')那么错误。

相关问题