[FIXED] Blueprint error in Flask: NameError: name of blueprint is not defined


I am just getting started with Flask and have been working on a very simple site to get acquainted with its main features before adding other stuff on and I’m getting, what seems to me, an inscrutable problem. I’ve looked at numerous tutorials and have no idea where I’m going wrong. My site directory is very simple:

├── ock/
│   ├── __init__.py
│   ├── .env
│   ├── routes.py
│   ├── templates/
│   │   ├── base.html
│   │   └── home.html
│   └── static/
│       └── style.css
├── instance/
│   └── config.py
├── venv/
├── setup.py
└── wsgi.py

__init__.py is here:

from flask import Flask, render_template

def make_app():
    app = Flask(__name__, instance_relative_config=True) 
    from . import routes

routes.py is here:

from flask import render_template, Blueprint
from wsgi import app

bp = Blueprint(
    'pages', __name__, 

def home():
    return render_template(

When I try to go to, it spit out: NameError: name ‘pages’ is not defined.

Edit to clarify question: How to do I get the blueprint to be recognized by Flask?


I figured out how to make it work. All I did was modify app.register_blueprint(pages) to app.register_blueprint(routes.pages). I guess that told Flask where to look for the blueprint?

So much left to learn.

Answered By – jprado

Answer Checked By – Timothy Miller (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published