Sending Form Data to Template - FLASK
In previous sections we saw how the http method can be specified in URL role. The Form data that is received by the triggered function, can collect it in form of dictionary object ,, and forward the same to a template to render it on the webpage. In the following example, ‘/’ URL renders a web page (student.html) which has a form. The data filled in it is posted to the ‘/result’ URL which triggers the result() function. The results() function collects form data present in request.form in a dictionary object and sends it for rendering to result.html . The template dynamically renders an HTML table of form data. Given below is the Python code of application − from flask import Flask , render_template , request app = Flask ( __name__ ) @app . route ( '/' ) def student (): return render_template ( 'student.html' ) @app . route ( '/result' , methods = [ 'POST' , 'GET' ]) def result (): if request . metho