Please Help
Why route in terminal work?
127.0.0.1 - - [17/Jan/2024 00:20:04] "POST /classification/ HTTP/1.1" 302 -
127.0.0.1 - - [17/Jan/2024 00:20:04] "GET /hasil/True-NORMAL2-IM-0421-0001.jpeg HTTP/1.1" 200 -
But it doesn't move to classification.html with params. Is that anything wrong?
Code :
dropzone = Dropzone(app)
@app.route('/classification/', methods=['POST','GET'])
def classification():
p = False
if request.method == 'POST':
f = request.files.get('file')
f.save(os.path.join(app.config['UPLOADED_PATH'],f.filename))
model = load_model('static/model/TA_resnet50 epoch50 imgsize200.h5')
model.make_predict_function()
img_path = "static/upload_images/"+f.filename
p = predict_label(img_path, model)
cursor.execute('INSERT INTO riwayat (userid, tanggal, hasil_klasifikasi, kode_citra) VALUES (%s, %s, %s, %s)', (session.get('userid'), '11/12/2014', p, f.filename))
cnx.commit()
img_name = f.filename
p = True
if p:
print("Reached redirect")
return redirect(url_for('hasil', p_val=p, img_name_val=img_name, _external=True ))
return render_template("classification.html")
@app.route('/hasil/<p_val>-<img_name_val>', methods=['GET'])
def hasil(p_val, img_name_val):
return render_template("classification.html", predict=p_val, img_name=img_name_val)
when route hasil run the page move to classification.html with params