且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Flask将HTML页面加载到HTML框架中

更新时间:2023-12-02 19:38:04

@ app.route('index.html')处创建另一条路线,渲染 index.html 模板,请确保 index.html 文件位于模板文件夹中

create another route at @app.route('index.html') rendering index.html the template, make sure the index.html file is in the templates folder

像这样:

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

资源需要从flask的 templates文件夹 static文件夹提供,您没有资源,可以自动将其提供令人难以置信的是不安全,因为任何用户都可以通过简单地更改链接来访问整个服务器.

resources need to be served from either the templates folder or the static folder in flask, you can't have a resource and have it automatically served as that would be incredibly insecure, since any user then will have access to your entire server by simply changing the link.