I am new to web development and I am stuck in a process that I need to render the same template with different values(in data shown in code) during 'POST' and 'GET'.
In my terminal, both get and post are invoked by the print statement in the python.
Majority of the code is taken from the 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)