url_for引发BuildError,但存在具有该名称和参数的视图

时间:2015-10-14 09:50:18

标签: python flask

我想在文本字段中添加自动填充功能。但是,当我尝试使用url_for将自动填充网址传递给JavaScript时,我得到werkzeug.routing.BuildError BuildError: ('autocomplete', {}, None)

退出app.url_map会显示<Rule '/autocomplete' (HEAD, OPTIONS, GET) -> autocomplete>

如何解决此错误?

@app.route('/autocomplete',methods=['GET'])
def autocomplete():
    URL = 'http://www.amis.pk/DistrictCities.aspx'
    City_Data = scrape(URL)
    City_Data = sorted(City_Data, key=lambda x: x.name)
    return jsonify(json_list=City_Data)
{{ url_for("autocomplete") }}

0 个答案:

没有答案