Differences

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

Link to this comparison view

ii:labs:s2:01:tasks:03 [2023/03/17 21:30]
florin.stancu removed
ii:labs:s2:01:tasks:03 [2024/03/15 13:30] (current)
florin.stancu [03. [20p] Making the list]
Line 1: Line 1:
-==== 03. Authentication ​====+==== 03. [25p] Making the list ====
  
-Now it'​s ​the time to add authentication to our website.+Solve these subtasks all in the same file (use ''​print()''​ statements ​to display the results):
  
-We will use the built-in Flask client-side encrypted sessions feature, for which will need to take the following ​steps to enable+Use the following ​list: <code python>​ 
 +sample = ["​a",​ 90, 8, "​X55",​ "​1z",​ 102, "​asdf",​ 65, 10, "​word",​ "​567",​ 567] 
 +</​code>​ 
 + 
 +Well:
  
-  * Import ​the ''​session'' ​field from ''​Flask'';​ +  * Sort the list (does it work? if not, why?); 
-  * Configure ​secret encryption key for the session cookies:<code python>​ +  * Reverse the list (this again? note: save the original one!); 
-# insert after initializing `app` +  * Filter out all non-numbers from the list (i.e., only ''​int'' ​type values should remain)... can you make it using **a single line of code**? now it's the time to introduce [[https://​docs.python.org/​3/​tutorial/​datastructures.html#​list-comprehensions|list comprehensions]];​ 
-app.config["​SECRET_KEY"​= "<​type some secret here>"​+<​note>​ 
 +Don't know how to check the type of a variable? 
 +[[https://​www.google.com/​search?​q=python+check+type+is+int|LMGTFY]]! 
 +</​note>​ 
 +  * Print the original list (remember the first 2 subtasks? [[https://​stackoverflow.com/​questions/​2612802/​how-do-i-clone-a-list-so-that-it-doesnt-change-unexpectedly-after-assignment|read this answer!]])
 +  * Define ​function that builds a matrix filled with numbers from 1 to n like the following example:<code python>​ 
 +m = [[1, 2, 3, 4], 
 +     ​[4, 1, 2, 3], 
 +     [3, 4, 1, 2], 
 +     [2, 3, 4, 1]]
 </​code>​ </​code>​
-  * Write the Flask functions for ''​login.html''​ and ''​logout.html''​ with the appropriate checks / actions. 
-  * Use the ''​authenticated''​ variable inside the Jinja template and conditionally display the user's status. 
  
  
ii/labs/s2/01/tasks/03.1679081440.txt.gz · Last modified: 2023/03/17 21:30 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