from flask import (
Flask, render_template)
from .database import DB
def create_app(test_config=None):
# create and configure the app
app = Flask(__name__, instance_relative_config=True)
app.config["MONGO_URI"] = "mongodb://localhost:27017/chpalinka"
DB.init()
# a simple page that says hello
@app.route('/')
def home():
return render_template('base.html')
from . import jegyzokonyv
app.register_blueprint(jegyzokonyv.bp)
return appjegyzokony.py
import functools
from flask import (
Blueprint, flash, g, redirect, render_template, request, session, url_for
)
from .database import DB
bp = Blueprint('jegyzokonyv', __name__, url_prefix='/jegyzokonyv')
@bp.route('/cefrezes', methods=('GET', 'POST'))
def cefrezes():
jegyzokonyvek = DB.get_all('cefreze')
return render_template('jegyzokonyv.html', query=jegyzokonyvek)
@bp.route('/fozes', methods=('GET', 'POST'))
def fozes():
pass
@bp.route('/erleles', methods=('GET', 'POST'))
def erleles():
pass以及base.html的导航部分
aa和错误信息:
File "D:WebPagesPalinka_Flaskflaskremplatesase.html", line 183, in top-level template code
File "D:WebPagesPalinka_Flaskvenvlibsite-packagesjinja2environment.py", line 430, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'jegyzokonyv' is undefined