Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ii:labs:s2:02:tasks:04 [2024/03/17 18:19]
florin.stancu created
ii:labs:s2:02:tasks:04 [2024/03/17 18:43] (current)
florin.stancu [04. [10p] Serving dynamic content]
Line 3: Line 3:
 Finally, we shall see how dynamic content can be interpolated ​ Finally, we shall see how dynamic content can be interpolated ​
  
-  * Edit the website'​s second HTML page, enter ''​{{mycontent}}''​ (this literal text!) as content somewhere inside the main content block: <​code>​+  * Edit the website'​s second HTML page, enter ''​%%{{mycontent}}%%''​ (this literal text!) as content somewhere inside the main content block: <​code ​html>
 <div class="​content-box main-content">​ <div class="​content-box main-content">​
 ... ...
Line 9: Line 9:
 ... ...
 </​code>​ </​code>​
-</​code>​ +  ​* Now modify the ''​server.py''​ code (the ''​second_page''​ function) to take in the desired value as a request parameter and pass it to the ''​mycontent''​ template variable, e.g.: <​code ​python>
-  ​* Now modify the ''​server.py''​ code (the ''​second_page''​ function) to take in the desired value as a request parameter and pass it to the ''​mycontent''​ template variable, e.g.: <​code>​+
 def second_page():​ def second_page():​
   render_template("​second.html",​ mycontent=request.args.get("​mycontent",​ "<​not specified>"​))   render_template("​second.html",​ mycontent=request.args.get("​mycontent",​ "<​not specified>"​))
 </​code>​ </​code>​
-  * Open the endpoint URL and pass the ''​mycontent''​ value as GET (//www-urlencoded//) parameter ​and see if the content changes dynamically after the request! +  * Open the endpoint URL and pass the ''​mycontent''​ value as a ''​GET'' ​//URL parameter// (e.g., ''?​parameter=value''​) and see if the content changes dynamically after the request! 
-  * This is a template engine called Jinja, seamlessly integrated with Flask (they have the same developers ;)! More about this: next time! +  * This is a template engine called Jinja, seamlessly integrated with FlaskMore about this: next time!
  
ii/labs/s2/02/tasks/04.1710692391.txt.gz · Last modified: 2024/03/17 18:19 by florin.stancu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0