LearnFlask with SQLAlchemy Basics

Treehouse
writes on February 25, 2021

Today we released “Flask with SQLAlchemy Basics,” an all-new course from Treehouse instructor Megan Amendola. This 147 minute Python course will teach you how to: Create a website or web app with Flask, connect a Flask website with an SQLite database using SQLAlchemy, create HTML templates, and connect static files.

You should learn Flask because… it’s simple to read and understand, and it’s versatile. It has a wide variety of applications, and supports numerous extensions. Companies like LinkedIn and Pinterest are using the Flask framework for their web applications.

In this article, you’ll learn:

What is Flask?

Flask is a popular Python framework for creating websites and/or web applications. A framework is a collection of code that makes building something easier. Flask will help us to create a website. Because it has written a lot of the code for us, we just need to learn how to use these new tools. Flask helps us work with the request-response cycle. Take a look at what that means with this clip that we shared on Twitter:

A user requests information from your site, your site determines how to handle the request and what information to send back, and then a response is sent to the user. So when a user asks for Treehouse’s homepage, the site will receive the request and send back the homepage’s information.

How to install Flask

Here’s how to create a virtual environment to practice using Flask. You can use whichever IDE (integrated development environment) that you’re comfortable with. Megan uses Visual Studio.

  1. Create a folder for your project
  2. Open your folder in your IDE
  3. Open the terminal in your IDE
  4. Create a virtual environment
    1. Mac: `python3 -m venv env`
    2. Windows: `python -m venv env`
  5. Activate your environment
    1. Mac: `source ./env/bin/activate`
    2. Windows: `.\env\Scripts\activate`
  6. Install Flask
    1. `pip install flask`
  7. Create requirements file
    1. `pip freeze > requirements.txt`

Now your project requirements file is ready if you want to create a repo for this project and others end up wanting to run your project to check it out. If you do want to post this on GitHub, then you can also create a .gitignore file. Inside write env to ignore this folder. Others will only need the requirements file to download the right packages and start your project.

Create a basic website with Flask with SQLAlchemy

Are you ready to jump into the world of Flask? Megan walks you through some of the basic steps in a livestream we shared this week. (You can sign up to stay notified of future livestreams from Treehouse instructors here.) Check it out:

Job titles and companies hiring Flask developers

Python Developers use Flask for a lot of the work related to their job, but they aren’t the only ones. Common job titles that use Flask include:

  • Software Engineer
  • Web Developer
  • Junior Web Developer

Companies that hire for roles that require Flask include:

  • Software companies
  • Creative agencies
  • Finance firms
  • E-commerce stores

There are 879 open positions that include “Flask Python Developer” keywords on Indeed.com right now, with salaries up to $150,000 per year.

Learn Flask with SQLAlchemy with Treehouse

Flask with SQLAlchemy Basics includes video instruction, code challenges, quizzes, and more. You can take the Treehouse course for free with a seven day free trial. Then, dive into more Python or SQL content with your Treehouse subscription. 

Related Treehouse Tracks for beginners:

Related Treehouse Courses:

Learning with Treehouse starts at only $25 per month. If you think you’re ready to start exploring if tech is right for you, sign up for your free seven day trial.

What sets Treehouse apart is their dedication to helping you find your perfect job or develop your own business. – SwitchUp.org

Follow us on TwitterInstagram, and Facebook for our favorite tips, and to share how your learning is going. We’ll see you there!

If you liked reading this article, you should also look at these three:

Leave a Reply

You must be logged in to post a comment.

Want to learn more about Python?

Learn the general purpose programming language Python and you will be able to build applications and tools.

Learn more