在Python Flask上加载引导时出错
我在flask中有以下代码app.py在Python Flask上加载引导时出错,python,twitter-bootstrap,flask,Python,Twitter Bootstrap,Flask,我在flask中有以下代码app.py 从烧瓶导入烧瓶,呈现模板,请求 从flask_引导导入引导 app=烧瓶(名称) 引导(应用程序) @应用程序路径(“/”) def home(): 返回渲染模板(“home.html”) 如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu': app.run() Where home.html: <!DOCTYPE html> <html lang="en" dir="ltr"> <he
从烧瓶导入烧瓶,呈现模板,请求
从flask_引导导入引导
app=烧瓶(名称)
引导(应用程序)
@应用程序路径(“/”)
def home():
返回渲染模板(“home.html”)
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
app.run()
Where home.html:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Cheppers DevOps Challeng | Home</title>
</head>
<body>
{% extends "template.html" %}
{% block content %}
{% endblock %}
</body>
</html>
我试图卸载并安装Flask引导程序,但仍然没有任何结果。我发现它出了什么问题
很明显,我导入的烧瓶引导程序库是错误的,pycharm无法识别。我发现在1.1.0版上运行的引导烧瓶看起来像是在html文件的某个地方调用的“引导”。也许在template.html中?
File "/Volumes/Data/final/web_cheppers/app.py", line 15, in home
return render_template("home.html")
File "/Volumes/Data/final/web_cheppers/venv/lib/python3.7/site-packages/flask/templating.py", line 140, in render_template
ctx.app,
File "/Volumes/Data/final/web_cheppers/venv/lib/python3.7/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/Volumes/Data/final/web_cheppers/venv/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/Volumes/Data/final/web_cheppers/venv/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/Volumes/Data/final/web_cheppers/venv/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Volumes/Data/final/web_cheppers/venv/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/Volumes/Data/final/web_cheppers/templates/home.html", line 8, in top-level template code
{% extends "template.html" %}
File "/Volumes/Data/final/web_cheppers/templates/template.html", line 47, in top-level template code
{% block scripts %}
File "/Volumes/Data/final/web_cheppers/templates/template.html", line 49, in block "scripts"
{{ bootstrap.load_js() }}
File "/Volumes/Data/final/web_cheppers/venv/lib/python3.7/site-packages/jinja2/environment.py", line 430, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'bootstrap' is undefined