Rest API with Python: FastAPI
- AltitudeCode
- Cheat sheet , Fast API
- December 20, 2023
FastAPI Setup Guide
Use the following commands to instal FastAPi on your local environment.(Mac/Windows)
- Mac
- Windows
Mac Commands
Navigate to Project Folder
cd Desktop
cd API
Navigate to the Desktop and then into the API project folder.
Check Python Version
python3 --version
Check if Python version 3.6 or above is installed.
Install Virtual Environment
pip3 install virtualenv
Install virtualenv using Python 3’s pip.
Create Virtual Environment
virtualenv env
Create a new virtual environment named ’env'.
Activate Virtual Environment
cd env
source bin/activate
Activate the virtual environment.
Return to Main API Directory
cd ..
Return to the main API project directory.
Install FastAPI
pip3 install fastapi
Install FastAPI using pip3.
Install Uvicorn
pip3 install uvicorn
Install Uvicorn, an ASGI server for FastAPI.
Windows Commands
Navigate to Project Folder
cd Desktop
cd API
Navigate to the API project folder.
Check Python Version
python --version
Check if Python version 3.6 or above is installed.
Install Virtual Environment
pip install virtualenv
Install virtualenv using pip.
Create Virtual Environment
virtualenv env
Create a new virtual environment named ’env'.
Activate Virtual Environment
cd env
cd Scripts
activate
Activate the virtual environment.
Return to Main API Directory
cd ..
Return to the main API project directory.
Install FastAPI and Uvicorn
pip install fastapi
pip install uvicorn
Install FastAPI and Uvicorn.