Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
href属性值在目标HTML页面的Python Flask应用程序中不起作用_Python_Flask - Fatal编程技术网

href属性值在目标HTML页面的Python Flask应用程序中不起作用

href属性值在目标HTML页面的Python Flask应用程序中不起作用,python,flask,Python,Flask,我有一个具有以下结构的基本烧瓶应用程序: app.py 模板/index.html static/js/common.js static/css/common.css 在我的index.html文件的顶部导航栏中,我希望菜单按钮包含指向其他html页面的链接。但是,当我尝试各种方法在标签的href属性中指定目标html文件时,它不起作用。单击后,页面无法加载。 在my index.HTML中提及目标HTML文件/路径的正确且快速的方法是什么 <body> &l

我有一个具有以下结构的基本烧瓶应用程序:

app.py

模板/index.html

static/js/common.js

static/css/common.css

在我的index.html文件的顶部导航栏中,我希望菜单按钮包含指向其他html页面的链接。但是,当我尝试各种方法在标签的href属性中指定目标html文件时,它不起作用。单击后,页面无法加载。 在my index.HTML中提及目标HTML文件/路径的正确且快速的方法是什么

    <body>
        <div class="navbar-header">
             <a href="index.html" class="navbar-brand"><strong>My Website</strong></a> 
        </div>
    </body>

模板(index.html)需要在Flask应用程序中通过路由呈现

要使用URL/index.html呈现index.html模板,请执行以下操作:

@app.route('/index.html')
def index():
    return render_template('index.html')
请参阅《快速入门指南》中的本节:

这可能值得同时通读整个指南。顺便说一句,在Flask中的URL中包含.html扩展名是非常不传统的,但这是您的决定