This shows you the differences between two versions of the page.
ii:labs:s2:01:tasks:02 [2023/03/17 21:30] florin.stancu removed |
ii:labs:s2:01:tasks:02 [2024/03/15 13:30] (current) florin.stancu [02. [20p] Let's do the math!] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 02. Integration with Flask backend ==== | + | ==== 02. [25p] Let's do the math! ==== |
- | We now want to move the design from a static ''html'' file to using Flask Jinja template rendering. | + | Python is also popular for its numeric manipulation features (it can handle very large numbers!). |
- | For this, you must: | + | Let's find out: |
- | * Migrate / split the HTML code to ''templates/_base.html'' (base template) and ''templates/index.html'' (child); | + | * Read a number from the console (you should know how to do it by now; don't forget to convert it to an ''int''!); |
- | * //Note:// use Jinja2 [[https://jinja.palletsprojects.com/en/3.1.x/templates/#template-inheritance|template inheritance]] with an empty content block; | + | * Reverse the number's digits and print the result (e.g., ''13568 => 86531'')! |
- | * Modify ''server.py'' to call ''render_template'' to actually serve our design. | + | * Define a new function, ''generate_prime(k)'', which takes in an argument and will generate a prime number of exactly ''k'' digits; use it to generate a 15-digit prime number (decrease this if it's taking too long '':('' )! |
- | * Also create ''about.html'' and a Python method for serving it (fill it with whatever content you want ;) ); | + | |
- | * Finally, fix the URLs in the template's menu to point to the appropriate pages. | + | |