Initial Project Configrations

Have a virtualenv: First things first, We need a virtual environment, A virtual environment is like a separate space wherein we can install our project requirements which is completely isolated from the global installations. Years back, When I was starting with Django, I used to install some requirements for some project(x) e.g. 

django==2.2
requests
email-validator==1.8.1
....

and after some days I would switch to some other project for some time. When I would come back to the original project (x), It would not work and strange errors would come. Later, I learned that I was always messing with the global installation.😄  Yup, I was this idiot!

Lets, make a project directory(folder) and cd into it. To make a virtual environment type the command: 

#cd to the project folder/directory

python -m venv env
#env is the name of virtual env

now activate the virtual environment. If you are in Windows use .\env\Scripts\activate Linux guys use  . env/bin/activate

 

Initializing Git:
One more thing is, We will be using git for version control. Version control is used mainly to do development in separate branches. Kind of virtual environment for code! It is also the Docter strange for our application. If something breaks then we can revert our code to some previous state.

Type the below command, and make sure you are in the project directory in terminal/cmd.

git init

Refer to the following screenshot in case you are confused, otherwise, you are good to go ðŸš—.

nofoobar@fastapi:~/Documents/algoholic.io$ pwd
/home/nofoobar/Documents/algoholic.io

nofoobar@fastapi:~/Documents/algoholic.io$ source ./env/bin/activate

(env) nofoobar@fastapi:~/Documents/algoholic.io$ git init
Initialized empty Git repository in /home/nofoobar/Documents/algoholic.io/.git/

Knowing what to ignore!
This mistake I used to make a lot when I started with development. I used to put my code to GitHub but I did not know about the .gitignore file and I used to send my virtualenv, SQLite DB, even once or twice the secret file with AWS secrets, and Stripe keys. Then, all of my accounts were closed by the AWS team, I also received a call from their team🥲 and I had to again configure all of that. Yup, I am a fool, and it's common to make mistakes, but the moral is to learn from them. So, I advise you to create a .gitignore file inside the directory. Copy the below lines and put them inside the .gitignore file.

__pycache__
.env
env
test_db.db

These lines simply mean that "git doesn't send over these files to GitHub". __pycache__ is to ignore the binary files which are created by Python. env folder is having third-party requirements which we can easily install, .env file will be having our secrets!

FastAPITutorial

Brige the gap between Tutorial hell and Industry. We want to bring in the culture of Clean Code, Test Driven Development.

We know, we might make it hard for you but definitely worth the efforts.

Contacts

Refunds:

Refund Policy
Social

Follow us on our social media channels to stay updated.

© Copyright 2022-23 Team FastAPITutorial