reading form inputs flask python | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

reading form inputs flask python

hi I used this codes to post a text from my HTML file to python and write it in a file but it doesn't work, actually, I think submit button is not working <table> <form action="{{ url_for('reports') }}" method="POST"> <tr> <td><input name="name"></td> <td><input name="terminal_number"></td> <td><input name="terminal_serial"></td> <td> <input name="ise"></td> <td><input type="submit"></td> </tr> </form> </table> AND in my .py file : def reports(): if 'user' in session: user = session['user'].is_admin() else: user=False if request.method == 'POST': text = request.form['name'] processed_text = text.upper() file2write=open("/testest.txt",'w') file2write.write("here goes the data") file2write.close() return processed_text return render_template('pages/reports.html',admin=user )

7th Mar 2018, 7:47 AM
hossein hayati
hossein hayati - avatar
1 ответ
+ 1
okay got it ... we shouldn't define form in table try this : <form action="{{ url_for('reports') }}" method="POST"> <table> <tr> <td><input name="name"></td> <td><input name="terminal_number"></td> <td><input name="terminal_serial"></td> <td> <input name="ise"></td> <td><input type="submit"></td> </tr> </table> </form>
7th Mar 2018, 7:48 AM
hossein hayati
hossein hayati - avatar