【发布时间】:2020-08-22 10:57:08
【问题描述】:
我是 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",q = "hello world",data = 1000)
【问题讨论】:
标签: javascript python flask audio backend