#!/usr/bin/env python # coding: utf-8 # # GOAL - Learn How to pass variables from the back-end to the front-end # Start by [downloading](http://bit.ly/1PmXydo) ***02 - Lesson*** and opening the ***app.py*** file. # class MainHandler(tornado.web.RequestHandler): # def get(self): # self.render('templates/index.html', # page_title = 'This is Amazing!!!', # page_heading = 'Welcome to Tornado' # ) # The only difference between the first lesson and this one is that we now have two new variables. What we are going to do is pass these two variables to the index.HTML page. # # **New Variables:**: # # * page_title # * page_heading # # Notice all we had to do is simply pass the variables inside the ***render*** function. # ## How do we accept variables on the HTML side of our web app? # # Remember that we have created two new variables named ***page_title*** and ***page_heading*** and we are passing these variables to the ***index.HTML*** page. # #### template.HTML # > Open the template.HTML page in lesson 2 # {{ escape(page_title) }} # In the template.HTML code you will see that instead of hard coding the title we have the ***page_title*** variable inside curly brakets. This is all we have to do in order to pass a variable from the ***app.py*** script into our ***template.HTML*** page. # #### index.HTML # # Now it's your turn... open the index.HTML page and see how we were able to pass the ***page_header*** parameter from the ***app.py*** script. # **Author:** [HEDARO](http://www.hedaro.com)