<commit_before>Week 6
======


In week 6 we will look at how to create a web application. 

Python has a rich ecosystem of tools for developing server-side web applications. 
We saw last week that we could very easily serve a single web page with the wsgiref package.
This is a useful starting point but for more complicated tasks leaves us with a lot of work to do.

A more popular approach is to use a framework that implements many of the common tasks we are likely to do.

* URI routing
* Sessions
* Database interaction
* Templating
* Error handling
* Security (but still need to be careful)

There are a `large number<https://wiki.python.org/moin/WebFrameworks/>`_ of very well developed frameworks available.

The two that are perhaps most popular currently are:

* `Django <https://www.djangoproject.com/>`_
* `Flask <http://flask.pocoo.org/>`_

We will be focusing on flask as django makes some assumptions that occasionally conflict with scientific data applications.



* Install Flask
* Convert our hello world example from wsgiref to flask
* Convert our hello world example to a template
* Fast introduction to HTML
* Add URI attributes
* Accept inputs
* Storing user supplied data


Assignments
-----------
* Install Flask
* Create a new page in our application
* Accept, store and display a first and last name


Files
-----

Please download the following files.

* `Web application <../wk06.zip>`_<commit_msg>Fixing typos in week 6<commit_after>Week 6
======


In week 6 we will look at how to create a web application. 

Python has a rich ecosystem of tools for developing server-side web applications. 
We saw last week that we could very easily serve a single web page with the wsgiref package.
This is a useful starting point but for more complicated tasks leaves us with a lot of work to do.

A more popular approach is to use a framework that implements many of the common tasks we are likely to do.

* URI routing
* Sessions
* Database interaction
* Templating
* Error handling
* Security (but still need to be careful)

There are a `large number <https://wiki.python.org/moin/WebFrameworks/>`_ of very well developed frameworks available.

The two that are perhaps most popular currently are:

* `Django <https://www.djangoproject.com/>`_
* `Flask <http://flask.pocoo.org/>`_

We will be focusing on flask as django makes some assumptions that occasionally conflict with scientific data applications.



* Install Flask
* Convert our hello world example from wsgiref to flask
* Convert our hello world example to a template
* Fast introduction to HTML
* Add URI attributes
* Accept inputs
* Storing user supplied data


Assignments
-----------
* Install Flask
* Create a new page in our application
* Accept, store and display a first and last name


Files
-----

Please download the following files.

* `Web application <../Wk06.zip>`_
{'fraction_non_alphanumeric': 0.06783216783216783, 'fraction_numerical': 0.003146853146853147, 'mean_word_length': 3.8822525597269624, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6470310', 'n_tokens_mistral': 778, 'n_tokens_neox': 733, 'n_words': 410}