我想实现点击按钮后只执行后台代码,不跳转或刷新页面,return render_template('')这一行我应该如何写?
app = Flask(__name__)
@app.route('/', methods=["GET", "POST"])
def ws_test():
if request.method == 'GET':
return render_template('ws.html')
else:
if request.form.get('button') == 'connection':
print(request.form['button'])
elif request.form.get('button') == 'disconnect':
print(request.form['button'])
elif request.form.get('button') == 'clear':
print(request.form['button'])
else:
print('数据错误')
return render_template('')