如何使用 python3 和 flask 从第二个 html 页面取回 index.html 页面?

问题描述 投票:0回答:0

我在主文件夹中有一个基本的 python3 脚本:

from flask import Flask,render_template
app=Flask(__name__)
@app.route('/')
def index():
    return render_template('index.html')
app.run(debug=True

“模板”文件夹中的一个简单的“index.html”文件:

<!doctype html>
    </head>
    <body>                
        <a href="static/cv.html">GOT TO CV</a>
    </body>
</html>

它完美运行并在“static”文件夹中打开“cv.html”:

<a href="index.html">BACK</a>

但是“cv.html”中的这个命令不起作用。错误信息说:

“获取/static/index.html HTTP/1.1” 404 -

看起来“index.html”应该在“static”文件夹中。 我怎样才能从主文件夹中取回“index.html”页面?

html python-3.x flask href
© www.soinside.com 2019 - 2024. All rights reserved.