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 in just seconds with a simple git push.
  • Use your own domain name, with automatic HTTPS certificate setup for secure connections managed for you.
  • Take advantage of automatic backups, one-click updates, and predictable pricing, so you can focus on your code instead of 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 comes with built-in support for routing, templating, and HTTP request handling, allowing 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'll see how to use it in the next steps.

After installing, 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.