我在一个页面上有一个表单,我想将其提交到另一个页面。我无法弄清如何创建到第二个页面的链接。
项目布局:
Fileserver/
config.py
requirements.txt
run.py
setup.py
app/
__init__.py
static/
css/
img/
js/
templates/
formAction.html
formSubmit.html
index.html
__init__.py
:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
ip = request.remote_addr
return render_template('index.html', user_ip=ip)
index.html
:
<!DOCTYPE html>
<html lang="en">
<body>
<ul>
<li><a href="/formSubmit.html">Check Out This Form!</a>
</ul>
</body>
</html>
没有问题,我可以在localhost:5000/上查看页面。
我还尝试过:
<a href="{{ url_for('templates', 'formSubmit") }}"></a>
以及:
<a href="{{ url_for('formSubmit') }}"></a>
我错过了什么?