如何解决Flask Python中未呈现不同的模板
我是Web开发的新手,我陷入了一个过程,我需要在“ POST”和“ GET”期间渲染具有不同值(代码中显示的数据)的相同模板。
在我的终端中,get和post都由python中的print语句调用。
大部分代码来自Record voice with recorder.js and upload it to python-flask server,but WAV file is broken
@app.route("/",methods=['GET'])
def index_GET():
print('data in get',data)
print('GET IS INVOKED')
return render_template("index.html",q = "hello world",data = 8)
@app.route("/",methods=['POST'])
def index_POST():
f = request.files['audio_data']
basepath = os.path.dirname(__file__)
x = str(datetime.datetime.now()).replace(" ","").replace(":","").replace(".","")+'.wav'
#upload to database folder uploads
with open(basepath+'/uploads/'+x,'wb') as audio:
f.save(audio)
print("POST IS INVOKED")
print(data)
print('-'.center(100,'-'))
return render_template("index.html",data = 1000)
解决方法
使用相同的路由处理这两种方法,然后使用Navigator.pushAndRemoveUntil(
context,MaterialPageRoute(builder: (BuildContext context) => PromotionsScreen()),(route) => false);
语句执行正确的操作:
if
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。