Apr-28-2020, 05:20 PM
I need help with this part for the code where i need to make a function that makes modification in the db file.
@app.route('/update/<commit>', methods=['GET', 'POST']) def update_record(commit): if request.method == 'GET': return render_template('whattoupdate.html', whichpath='/update/search') elif request.method == 'POST': if commit == 'search': searchtext=request.form['searchtext'] updatelist=[] index=0 with open('mycontacts.db', 'r') as db: for line in db: line=line.rstrip() if searchtext in line: updatelist.append([index, line]) index+=1 return render_template('visualisecontacts.html', whichpath=url_for('update_record', commit='write'), contactdb=updatelist) elif commit == 'write': return "I need help with this part" else: abort(400) else: return "Invalid request"