小编Ric*_*ael的帖子

如何创建指向另一个html页面的链接?

我在一个页面上有一个表单,我想提交到另一个页面.我无法弄清楚如何创建到第二页的链接.

项目布局:

Fileserver/
    config.py
    requirements.txt
    run.py
    setup.py
    app/
        __init__.py
        static/
            css/
            img/
            js/
        templates/
            formAction.html
            formSubmit.html
            index.html
Run Code Online (Sandbox Code Playgroud)

__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)
Run Code Online (Sandbox Code Playgroud)

index.html:

<!DOCTYPE html>
<html lang="en">
<body>
    <ul>
        <li><a href="/formSubmit.html">Check Out This Form!</a>
    </ul>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我可以在localhost:5000 /看到页面没有问题.

我也尝试过:

<a href="{{ url_for('templates', 'formSubmit") }}"></a>
Run Code Online (Sandbox Code Playgroud)

以及:

<a href="{{ url_for('formSubmit') }}"></a>
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

python flask

12
推荐指数
1
解决办法
5万
查看次数

标签 统计

flask ×1

python ×1