我想在Flask中获取复选框的值.我已经阅读了类似的帖子,并尝试使用输出,request.form.getlist('match')因为它是我使用的列表[0],但似乎我做错了.这是获得输出的正确方法还是有更好的方法?
<input type="checkbox" name="match" value="matchwithpairs" checked> Auto Match
Run Code Online (Sandbox Code Playgroud)
if request.form.getlist('match')[0] == 'matchwithpairs':
# do something
Run Code Online (Sandbox Code Playgroud) 所以我遇到的问题是我的网络应用程序有时只加载css文件,它使用相同的css文件数据,即使我对css文件进行了编辑,甚至当我删除文件时也加载了.我不知道发生了什么.我注意到,当它正确加载css时,会显示以下消息:
127.0.0.1 - - [08/Jun/2015 14:46:19] "GET /static/style.css HTTP/1.1" 200
我的style.css文件位于一个名为的文件夹下static,在我的html文件中
<link type='text/css' href='{{ url_for('static', filename='style.css') }}' rel='stylesheet'>
Run Code Online (Sandbox Code Playgroud) 我想在我的页面上实现动画,当一个漫长的过程(如下面的Python Flask路线)正在运行时,它会在完成后消失.我怎样才能做到这一点?
@app.route('/test', methods=['GET','POST'])
def test():
if request.method=="POST":
if request.form.get('updatepaths')=='Update' and form.validate_on_submit():
Fname = form.name.data
Lname=form.name2.data
TimeConsumingFunction(Fname)
TimeConsumingFunction(Lname)
Run Code Online (Sandbox Code Playgroud)