Search code examples
flaskcookiecutter

cookiecutter-flask route 404 for new module


I started a new cookiecutter-flask app today (v. 0.10.1). I'm having a problem getting it to recognize that a route has a template defined. Here is the views.py for the module.

# -*- 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)

There is no error message besides "GET /spreadsheets/list HTTP/1.1" 404 - when trying to reach http://127.0.0.1:5000/spreadsheets/list. I thought I'd followed the example users/views.py and I've checked what does and doesn't get the pluralized form s several times.

Any thoughts?


Solution

  • In app.py in the def register_blueprints(app): function I needed to add:

    app.register_blueprint(spreadsheet.views.blueprint)