Building Serverless Python Web Services with Zappa
上QQ阅读APP看书,第一时间看更新

Installing Flask

Flask mainly depends on two external libraries such as Werkzeug and Jinja2. Werkzeug provides a Python standard WSGI (Web Server Gateway Interface) that enables a Python application to interact with HTTP. Jinja2 is a templating engine that enables you to render an HTML template with your own customized context.

Now, let's move on and install Flask. All its dependencies will be automatically installed; you don't need to install dependencies manually.

It's recommended that you use virtualenv to install Flask, since virtualenv enables you to install Python packages in parallel for different Python projects.

If you don't have virtualenv, then you can simply install it by using the following code:

$ sudo apt-get install python-virtualenv

Once you have installed virtualenv, you need to create a new environment for your Flask project, as shown in the following screenshot:

We will be using virtualenv in the upcoming sections. Now, let's install Flask:

$ pip install flask

We are ready to have fun with Flask. We will be creating a minimal Flask application to demonstrate the Flask application workflow.