用于新模块的cookiecutter-flask路线404

时间:2016-09-03 20:34:25

标签: flask cookiecutter

我今天开始使用新的cookiecutter-flask应用(第0.10.1节)。我有一个问题,让它认识到路线有一个模板定义。这是模块的views.py。

# -*- coding: utf-8 -*-
"""Spreadsheet views."""
from flask import Blueprint, render_template
from flask_login import login_required

blueprint = Blueprint('spreadsheet', __name__, url_prefix='/spreadsheets', static_folder='../static')


@blueprint.route('/list') #/spreadsheets/list
@login_required
def list():
    """List spreadsheets of user logged in."""
    files = {name: 'Test', uploaded_by: 1}
    return render_template('users/spreadsheets.html', files=files)

尝试访问http://127.0.0.1:5000/spreadsheets/list时,除了"GET /spreadsheets/list HTTP/1.1" 404 -之外没有任何错误消息。我以为我已经按照示例users / views.py进行了检查,并且我已经多次查看了复数形式的内容和内容。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

app.py函数的def register_blueprints(app):中,我需要添加:

app.register_blueprint(spreadsheet.views.blueprint)