【发布时间】:2014-12-18 04:35:31
【问题描述】:
我在一个页面上有一个表单,我想提交到另一个页面。我不知道如何创建指向第二页的链接。
项目布局:
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>
我错过了什么?
【问题讨论】: