Let's now focus on another Python Web framework called Flask. In this lecture, we will overview Flask and how it works as well as the given example in Flask to act as a web-based recommended product. Flask is a Python micro-framework, built for web application development. Micro-framework means that it has no or very little dependencies to external libraries which makes it lightweight and secure. But it also means that you sometimes need to install your libraries. Many popular websites we use today are built using Flask including Netflix, Uber, Lyft, and Airbnb. Here, we show how a web request flows down into a Flask application. You start with a web request on top, like get post requests, and that requests will be routed to a web server, which will then send the request info to the application server. The application server is running the Flask application and is connected through the Flask framework. The Flask app gets the request and forces it to find the correct route. The route is associated with a Python function which is then executed, and results are returned up the stack finally as a response to the initial web line request. Similar to Django's Model-View-Template or MVT Architecture, Flask is built using what we call generally a Model-View-Controller, MVC Architecture. Code is built in this way so that you can change something in one section without necessarily having to change it in the other section. The HTTP request comes in, and the controller code is executed which is the Python function. Data is gathered and put into the model class, and then this model is passed to the view in order to construct the presentation of the data. When building your web application with Flask and Python, to start with Flask, you have to import the module, and then create a Flask object. Then, you call a run on that object. You can define routes that will call different functions when an HTTP request is generated for them. In this example, the route /route is defined for an HTTP get request. The index function will be executed and produce 'hello from flask' and 'hello from flask' will be returned from the form in the response object. Here is some code as excerpt from our recommender example which gets data from a machine learning object and puts it in the model object which then is rendered as a template using the model view control framework. The route /items/similar is defined for GET and POST requests. The function similar_item_form will be executed for the route. The form variable is the model in the Model-View-Controller or MVC, and it's set to a new similar_items_form object. For a POST request, it will automatically fill in with the variables for the model from the POST request. If it's a POST request, then it will call the machine learning code to get the similar items in the function call, mlModel.get_similar_items. So this is a function call to get the similar items. We pass in the item_id passed in from the post request object here, and finally, the results of this will be rendered out to the similar.html view, the V in the MVC. So we'll pass in the form object all the data. So the form object, they'll hold all the data. Flask also provides HTML templates to describe the view. Again, the V in the MVC. You can print out Python variables and run Python logic through such templates. You can pass in a model M in the MVC to work with in the view. So in this example, the data dictionary is passed into our view, and Python logic which is enclosed in the curly brackets and the percentage signs, and if you want to print out variables, you will enclose them and use double brackets. So in this example, we are looping over items in a list, and printing out the ID, and title for each item. Next, we provide you with a Docker container to run your first Flask application. You might not know about Docker, don't panic. Because although you can install and run everything locally, having it in a container like Docker will help you to not worry about installing Flask separately for now. So you can focus on learning Flask rather than installing it. As a side note for the ones who heard containers for the first time. Containers are lightweight images that has all the dependencies like libraries and binary executables you need to run a process. In this case, that process will be your Flask. In the package, we provide you a file called Docker-compose.yml which holds instructions on how to build and run your Docker image. The Docker file holds instructions on how to build the image. For instance, if you were to build it yourself locally, you would go through those instructions. Once the image is built, Docker /compose will run the image, and create the container. It will also mount the local disk into the container so that you can work on files locally, and edit them in real-time. Finally, it exposes ports so that you can talk with this container. So in this lecture, we shortly reviewed flask and how its MVC architecture works. We also introduced a Flask container that you will be using next to practice with Flask. Please go through the short reading to install and run your first Flask application. Again, if you have any questions in this process, please make sure to use the course forums, and get the help you need as a set of Q&A.