这是我的wsgi.py
:
from flask import Flask, render_template, url_for
app = Flask(__name__)
DEVELOPMENT = {}
PRODUCTION = {
"host": "0.0.0.0",
"port": "5000"
}
running_mode = DEVELOPMENT
@app.route('/')
def index():
return render_template("index.html")
@app.route('/#index_content')
def index_content():
return render_template("index_content.html")
if __name__ == '__main__':
if running_mode:
app.run(running_mode["host"], running_mode["port"])
else:
app.run()
这是我的index.html
:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Gerenciador de Adquirentes</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="Concil">
<link rel="stylesheet" href="{{url_for('static', filename='materialize/css/materialize.min.css')}}">
<link rel="stylesheet" href="{{url_for('static', filename='concil.css', v=0.01)}}">
</head>
<body>
<section id="main">
</section>
<script src="{{url_for('static', filename='materialize/js/materialize.min.js')}}"></script>
<script src="{{url_for('static', filename='jquery-3.3.1.min.js')}}"></script>
<script src="{{url_for('static', filename='hashy-content.js')}}"></script>
<script>
$(document).ready(function () {
$("#main").load("/#index_content");
});
</script>
</body>
</html>
当我使用路由'/#index_content'
,而不是加载索引的内容时_内容.html,它开始发出无休止的请求,重新加载页面。It doesn't work as in this example。如何在烧瓶中动态加载内容物?我不想为每个视图重复html标记。你知道吗
你的
/#index_content
路由永远不会被点击,因为#
是由浏览器处理的。它永远不会到达你的烧瓶后端。事实上,flask会将这个javascript请求看作是/
(自己查看request.url
),所以本质上发生的事情是-一旦页面加载,javascript只会导致页面刷新,因此是无限循环。你知道吗我可以建议将端点名称改为
@app.route('/index_content')
,然后点击它。你知道吗相关问题 更多 >
编程相关推荐