jinja2.exceptions.TemplateSyntaxError: expected token ',', got 'string' and TypeError: 'function' object is not subscriptable
jinja2.exceptions.TemplateSyntaxError: expected token ',', got 'string' and TypeError: 'function' object is not subscriptable
我尝试运行/homepage
@app.route('/')
def index():
return redirect(url_for(homepage))
@app.route('/homepage')
def homepage():
return render_template('fullcalendar.html')
遇到错误:
TypeError: 'function' object is not subscriptable
当我在地址栏 127.0.0.1:5000/homepage 中写入时出现此错误:
File "/home/pc/shudleApp1/env/lib/python3.6/site-packages/flask/helpers.py", line 318, in url_for
if endpoint[:1] == ".":
TypeError: 'function' object is not subscriptable
fullcalendar.html
<link href="{{ url_for('static', filename=css/fullcalendar.css') }}"/>
<link href="{{ url_for('static', filename= css/fullcalendar.print.css') }}" />
<script src="{{ url_for('static', filename=js/jquery-1.10.2.js' }}"></script>
<script src="{{ url_for('static', filename=js/jquery-ui.custom.min.js') }}"></script>
<script src="{{ url_for('static', filename=js/fullcalendar.js') }}"></script>
<script>
在 redirect(url_for(homepage))
中,您将传递给 url_for
homepage
,这是您的 函数 而不是您的主页端点。
你应该通过 '/homepage'
我尝试运行/homepage
@app.route('/')
def index():
return redirect(url_for(homepage))
@app.route('/homepage')
def homepage():
return render_template('fullcalendar.html')
遇到错误:
TypeError: 'function' object is not subscriptable
当我在地址栏 127.0.0.1:5000/homepage 中写入时出现此错误:
File "/home/pc/shudleApp1/env/lib/python3.6/site-packages/flask/helpers.py", line 318, in url_for
if endpoint[:1] == ".":
TypeError: 'function' object is not subscriptable
fullcalendar.html
<link href="{{ url_for('static', filename=css/fullcalendar.css') }}"/>
<link href="{{ url_for('static', filename= css/fullcalendar.print.css') }}" />
<script src="{{ url_for('static', filename=js/jquery-1.10.2.js' }}"></script>
<script src="{{ url_for('static', filename=js/jquery-ui.custom.min.js') }}"></script>
<script src="{{ url_for('static', filename=js/fullcalendar.js') }}"></script>
<script>
在 redirect(url_for(homepage))
中,您将传递给 url_for
homepage
,这是您的 函数 而不是您的主页端点。
你应该通过 '/homepage'