Differences

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

Link to this comparison view

ii:labs:s2:01:tasks:04 [2022/04/01 13:05]
florin.stancu [04. Bonus: File upload]
ii:labs:s2:01:tasks:04 [2024/03/15 13:30] (current)
florin.stancu [04. [20p] Word Map]
Line 1: Line 1:
-==== 04. Advanced: File upload ​====+==== 04. [25p] Word Map ====
  
-As a final taskwe want to upload some files using our web application. +Firsttake couple ​(3-4of paragraphs ​[[https://www.gutenberg.org/files/2701/2701-h/2701-h.htm#link2HCH0001|from here]] and store them inside a ''​.txt''​ file.
- +
-  * Create ​new ''​upload.html''​ form page with a ''<​input type=file ...>''​ field (and, ofc., a submit button!)+
-    * Note: you need to use ''​multipart/​form-data''​ form encoding for HTTP file uploading to work. +
-  * Create the appropriate Flask route that serves the ''​upload.html''​ page; +
-    * Check Flask'​s ​[[https://flask.palletsprojects.com/en/2.1.x/api/#incoming-request-data|''​Request'' ​object reference]] for accessing the uploaded files; +
-  * Enhance your route function to save the uploaded ​file on disk (e.g., the ''​upload/''​ directory);​ +
-  * Finally, test it!+
  
 +  * Open the file and read its contents into string;
 +  * Build a ''​dict''​ with each word from this text (lower cased as key), counting their frequency (as its value);
 +  * Use it to print out the most frequent 5 words in this text (together with their value!), e.g.:
 +<​code>​
 +[('​the',​ 29), ('​of',​ 18), ('​and',​ 15), ('​to',​ 10), ('​a',​ 9)]
 +</​code>​
  
ii/labs/s2/01/tasks/04.1648807508.txt.gz · Last modified: 2022/04/01 13:05 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