Python web frameworks (https://wiki.python.org/moin/WebFrameworks) provide a collection of packages that allow developers to focus on the core logic of the application rather than having to handle low-level details (for example, protocols, sockets or process, and thread management, among others). Furthermore, these frameworks can be categorized into full-stack and non-full-stack frameworks. Django and Flask are two popular web frameworks for Python, which we will discuss later on in this chapter:
The perfect example of a Full-stack frameworks is Django (https://www.djangoproject.com/), which is a free, open source, full-stack Python framework, trying to include all the necessary features by default, as opposed to offering them as separate libraries. Django makes it easier to create web applications, and requires less time than other frameworks. It focuses on automating as much as possible by following the principle of don't repeat yourself (DRY). If you are interested in learning Django, we recommend you read this tutorial, which is about writing your first Django application (https://docs.djangoproject.com/en/2.1/intro/tutorial01/).
Flask, which is available under the BSD license, can be considered as the perfect example of non-full-stack frameworks. Indeed, Flask is considered a micro-framework, which is a framework with few or no dependencies on external libraries.
Flask has the following dependencies:
- Werkzeug WSGI toolkit (http://werkzeug.pocoo.org/):
- A WSGI utility library
- Jinja2 (http://jinja.pocoo.org/):
- A template engine
Both Django and Flask can be used to develop computer vision and deep learning applications. However, it is generally accepted that Django has a slightly steeper learning curve than Flask. Additionally, Flask focuses on minimalism and simplicity. For example, Flask's Hello World application is only a few lines of code. Moreover, Flask is also recommended for smaller and less complicated applications, whereas Django is commonly used for larger and more complex applications.
In this chapter, we are going to see how Flask can be used to create computer vision and deep learning web applications.