Python: Installing the Flask dependency

This documentation is part of the Creating a REST API guide. You can view the complete guide here: Step-by-step guide to building a REST API with Flask in Python.

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Python cloud solution designed to simplify your deployments:

  • Deploy your application to production within seconds using a simple git push.
  • Use your own domain name, with automatic HTTPS certificate setup for secure connections managed on your behalf.
  • Take advantage of automatic backups, one-click updates, and predictable pricing, so you can focus on your code rather than infrastructure management.
  • Benefit from high performance and security on a private, dedicated infrastructure. Your environment is isolated and protected.

Save time and streamline your workflow: your code can be up and running with Stackhero's Python cloud hosting in just 5 minutes.

You only need one main dependency for this example: Flask.

Flask is designed to be simple and fast, so you can build and deploy web APIs without unnecessary overhead. It includes built-in support for routing, templating, and HTTP request handling, enabling you to go from idea to working API in just a few minutes.

You can install Flask and python-dotenv using pip:

pip install Flask python-dotenv

We include python-dotenv to manage environment variables securely and conveniently. You will see how to use it in the following steps.

After installation, freeze your dependencies to a requirements.txt file:

pip freeze > requirements.txt

Freezing dependencies ensures everyone uses the same package versions. This small step can save you hours of troubleshooting later on.