小编Mar*_*k T的帖子

如何使用flask将内容加载到div元素中

我想用 python 函数的结果填充/更新 index.html 中的 div 区域,但我不知道该怎么做。我知道还有其他几个具有类似主题的问题,但我无法成功解决它们,因为它们太具体了。我正在为此抓狂。
会有这么好的人来指导我吗?
这是 main.py 中的一个函数:

@app.route('/')
    
    def index():
        return render_template('index.html')
        
 @app.route('/stat/')
        
        def stat():
        
            a = 2
            b = 10
        
            return(str(a) + ' is not ' + str(b))
Run Code Online (Sandbox Code Playgroud)

这是index.html:

<body>

    <form action="/stat/"> 

    <button type="submit" id="btn1" class="btn btn-primary btn-sm">check stat</button>

    </form>

 <div id="stat_content"></div>

</body>
Run Code Online (Sandbox Code Playgroud)

html python flask

2
推荐指数
1
解决办法
6001
查看次数

标签 统计

flask ×1

html ×1

python ×1