我已经搜索了所有我能找到的包括这个,flask blueprint template folder。
/root
__init__.py
run.py
/hrms
__init__.py
views.py
models.py
/static
/templates
__init__.py
layout.html
/hr
__init__.py
hr_template_test.html我也尝试过:
/hrms
__init__.py
views.py
models.py
/templates
__init__.py
hr_template_test.html无论我把hr_template_test.html文件放在哪里,Flask都找不到它。下面是我在__init__.py中拥有的内容
from flask import Blueprint, render_template
hrms_blue = Blueprint('hrms', __name__, template_folder='templates')
@hrms_blue.route('/')
def index():
return render_template('hrms_data_view.html')在run.py中
from flask import Flask
from flask_debugtoolbar import DebugToolbarExtension
from application.views.hrms import hrms_blue
app = Flask(__name__)
app.register_blueprint(hrms_blue, url_prefix='/<hrms_id>')我试过了:
return render_template('hr/hrms_data_view.html')
return render_template('application/templates/hr/hrms_data_view.html')
return render_template('templates/hr/hrms_data_view.html')
return render_template('hrms_data_view.html')
http://127.0.0.1/hrmsJinja2抱怨说它找不到html文件。
我从模板和hr中取出了__init__.py。不我明白了TypeError: index() takes no arguments (1 given)。
发布于 2015-03-25 03:29:02
您可能遇到了循环导入的问题。您应该尝试执行以下操作:
def register(app):
from __init__ import hrms_blue
app.register_blueprint(hrms_blue)
register(app)而不是做:
app.register_blueprint(hrms_blue, url_prefix='/<hrms_id>')https://stackoverflow.com/questions/29239935
复制相似问题