我想更改flask变量的值
当用户单击链接时
诸如此类
(我试过这种方法,但其中一种不起作用)
<a href="#" onclick=" {% set data = true %}">sutfile</a>
因为稍后我有下面的循环,我想填充select标记
仅当布尔值=true时
<label>vCenterAddress:<select> {% if data == true %} {% for a in vCenterAddress %} <option value="">{{ a[0] }}</option> {% endfor %} {% endif %}</select></label>
route.py中的布尔过程
@app.route("/", methods=['GET', 'POST'])
def index():
cur = mysql.connection.cursor()
vCenterAddress = cur.execute(f"SELECT DISTINCT vCenterAddress FROM linux0 where vCenterAddress <> \"None\" ")
vCenterAddress = cur.fetchall()
data_to_show: bool = False
return render_template('index.html', vCenterAddress=vCenterAddress, data=data_to_show)
下面是我在评论中建议的更详细的解释
你需要让你的flask服务器“监听”你的url应用页面
所以您需要导入请求
像这样:
现在在
def index():
中,您需要添加你的html链接
现在,当您单击链接时,新的url就是您的页面,var name=true
在flask服务器中,var=true和if条件将起作用
相关问题 更多 >
编程相关推荐