如何在Flask中解决此for_url错误(“ SyntaxError:'/ upload'不是有效的选择器”)?

时间:2019-01-24 17:57:03

标签: html url flask

我在Flask中遇到以下问题,

在我的模板文件夹中-

我有三个HTML文件:

  • index.html
  • database.html
  • upload.html

server.py

 from flask import Flask, url_for,redirect, render_template

app = Flask(__name__)

@app.route('/')
def index():
return render_template('index.html')

 @app.route('/upload')
 def upload():
 return render_template('upload.html')

 @app.route('/database')
 def database():
return render_template('database.html')

if __name__ == '__main__':
app.run(debug=True)

index.html

  <a class="nav-link js-scroll-trigger" href="{{ url_for('upload')}}">Upload    File</a>

  <a class="nav-link js-scroll-trigger" href="{{ url_for('database')}}">Protein    Database</a>

我在Firefox的Web控制台上收到的错误:

 SyntaxError: '/upload' is not a valid selector bootstrap.bundle.min.js:6 

Chrome出现错误:

Failed to execute 'querySelector' on 'Document': '/upload' is not a valid selector.
at Object.getSelectorFromElement 

请问如何解决此错误,我们将不胜感激

非常感谢,

Ishack

0 个答案:

没有答案