Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Project Initialization | Introduction to the Course
course content

Contenido del Curso

Professional Web API with Flask

Project InitializationProject Initialization

You're already familiar with setting up a Flask project from our previous intensive Flask course. However, we're going to delve deeper and explore a range of advanced topics and practices. By the end of this course, we'll aim to deploy a project that could serve as your pet project.

GitHub

Let's begin with GitHub, which serves as a free remote repository for projects. I encourage you to complete this course to become proficient with GitHub—a valuable skill to highlight on your resume.

Please make sure you're logged into GitHub. I've already done so. Go ahead and create a new project and name it fc_manager_api. Be sure to check the option to Add a Readme file, ensuring our project isn't entirely empty. After creating the repository, navigate inside it, click on the Code button, and copy the HTTPS URL.

Next, open the terminal on your computer and navigate to the directory where you wish to store the project. Use the command cd dir_name to enter a folder, cd .. to go back, and ls to view the folder's contents.

Once in the desired folder, execute the command git clone [your-repository-URL], making sure to replace [your-repository-URL] with the actual URL of your newly created fc_manager_api repository and hit Enter. Verify the folder's contents to see that the git repository has been cloned. Move into this folder with the command cd fc_manager_api and check if the README file is present with the ls command. Excellent. Now, let's open this directory in our IDE. I'll be using PyCharm, but feel free to use VScode or another IDE of your choice.

With our project directory open, let's begin the setup.

Virtual Environment

Open your IDE's terminal and enter the command:

to create a virtual environment. You'll notice a new folder created with the necessary virtual environment settings. Activate the environment on macOS with :

which will change the terminal prompt, indicating the environment is active. I'll also need to select the correct environment in my case.

For Windows use:

Virtual environment is important of isolating project dependencies to avoid conflicts between projects.

Project Initialization

Next, we'll install Flask with:

Shortly after, you should see a message confirming the successful installation of Flask and its dependencies.

Now, let's create an 'app.py' file to initialize our Flask app. Right-click on the root folder, select 'New' -> 'File', and confirm.

We need to import Flask and then initialize a new app.

__name__ is a special variable that Python sets to the name of the module in which it is used. This is a straightforward command. Set up a secure secret key for the app with:

Use a service to generate a secure key. Remember, this is sensitive information, so keep it private.

Now, you can run your application by running in terminal:

This command searches for app.py and runs the script inside the file.

¿Todo estuvo claro?

Sección 1. Capítulo 5
course content

Contenido del Curso

Professional Web API with Flask

Project InitializationProject Initialization

You're already familiar with setting up a Flask project from our previous intensive Flask course. However, we're going to delve deeper and explore a range of advanced topics and practices. By the end of this course, we'll aim to deploy a project that could serve as your pet project.

GitHub

Let's begin with GitHub, which serves as a free remote repository for projects. I encourage you to complete this course to become proficient with GitHub—a valuable skill to highlight on your resume.

Please make sure you're logged into GitHub. I've already done so. Go ahead and create a new project and name it fc_manager_api. Be sure to check the option to Add a Readme file, ensuring our project isn't entirely empty. After creating the repository, navigate inside it, click on the Code button, and copy the HTTPS URL.

Next, open the terminal on your computer and navigate to the directory where you wish to store the project. Use the command cd dir_name to enter a folder, cd .. to go back, and ls to view the folder's contents.

Once in the desired folder, execute the command git clone [your-repository-URL], making sure to replace [your-repository-URL] with the actual URL of your newly created fc_manager_api repository and hit Enter. Verify the folder's contents to see that the git repository has been cloned. Move into this folder with the command cd fc_manager_api and check if the README file is present with the ls command. Excellent. Now, let's open this directory in our IDE. I'll be using PyCharm, but feel free to use VScode or another IDE of your choice.

With our project directory open, let's begin the setup.

Virtual Environment

Open your IDE's terminal and enter the command:

to create a virtual environment. You'll notice a new folder created with the necessary virtual environment settings. Activate the environment on macOS with :

which will change the terminal prompt, indicating the environment is active. I'll also need to select the correct environment in my case.

For Windows use:

Virtual environment is important of isolating project dependencies to avoid conflicts between projects.

Project Initialization

Next, we'll install Flask with:

Shortly after, you should see a message confirming the successful installation of Flask and its dependencies.

Now, let's create an 'app.py' file to initialize our Flask app. Right-click on the root folder, select 'New' -> 'File', and confirm.

We need to import Flask and then initialize a new app.

__name__ is a special variable that Python sets to the name of the module in which it is used. This is a straightforward command. Set up a secure secret key for the app with:

Use a service to generate a secure key. Remember, this is sensitive information, so keep it private.

Now, you can run your application by running in terminal:

This command searches for app.py and runs the script inside the file.

¿Todo estuvo claro?

Sección 1. Capítulo 5
some-alt