Welcome to the FastAPI Learning repository! This collection of projects is designed to help you learn and explore FastAPI, a modern web framework for building APIs with Python.
- Overview of the Repository
- Setting Up the Development Environment
- Additional Requirements
- Running the Projects
- License
- Credits
This repository features four practical FastAPI projects, each with its own unique focus and learning opportunities:
This project provides a straightforward example of FastAPI in action. It serves as a great starting point for understanding the basics of FastAPI development.
In this project, you'll find a simple item management API with fundamental API endpoints. It's an excellent resource for getting hands-on experience with FastAPI for building RESTful services.
This project introduces you to a To-do app built using FastAPI. You'll learn how to perform CRUD (Create, Read, Update, Delete) operations, a key skill for building robust APIs.
In this project, you'll delve into the integration of FastAPI with a machine-learning model. It offers a practical example of how FastAPI can be used in real-world applications, particularly in ML-based projects.
π₯ Feel free to explore each project, experiment with the code, and expand your FastAPI knowledge.
Happy learning! π
Follow these steps to set up your development environment for this project:
-
Navigate to your project directory:
cd /path/to/your/project
-
Create a virtual environment:
python -m venv <venv_name>
-
In
cmd
:<venv_name>\Scripts\activate
-
In bash:
source <venv_name>/Scripts/activate # To deactivate the virtual environment: deactivate
-
Use Anaconda Navigator to create a venv:
# Activate the conda environment conda activate <venv_name> # To deactivate the conda environment conda deactivate
- You can also use a
requirements.txt
file to manage your project's dependencies. This file lists all the required packages and their versions.
-
Install packages from
requirements.txt
:pip install -r requirements.txt
This ensures that your development environment matches the exact package versions specified in
requirements.txt
. -
Verify installed packages:
pip list
This will display a list of packages currently installed in your virtual environment, including the ones from
requirements.txt
.
For a smoother development experience, consider installing the following additional requirements:
πNote: FastAPI, Uvicorn, and Pydantic are listed inside the requirements.txt
.
-
FastAPI: A modern web framework for building APIs with Python.
-
Uvicorn: A lightning-fast ASGI server for running FastAPI applications.
-
Pydantic: A data validation and parsing library.
-
Jupyter Notebook: An interactive computing environment for creating and sharing documents containing live code, equations, visualizations, and narrative text.
Feel free to install these requirements using pip
or include them in your requirements.txt
file if they are not already present.
You can include any additional requirements or tools that you find useful for your project development in the "Additional Requirements" section.
Follow these steps to run the projects in your FastAPI Learning repository. Open your Bash terminal and navigate to the project directory:
cd <project_directory>
-
To run the
simple-example
anditem-api
projects, use the following command:uvicorn main:app --reload
-
You can access the project output in your browser using the following URL:
http://127.0.0.1:8000
-
To explore the API documentation, visit:
http://127.0.0.1:8000/docs
-
To run the other two projects, use the following command:
python main.py
-
You can access the project output in your browser using the following URL:
http://127.0.0.1:8000
-
To explore the API documentation, visit:
http://127.0.0.1:8000/docs
Enjoy exploring and running the FastAPI projects!
This project is licensed under the MIT License. See LICENSE for more details.
I would like to extend my gratitude to the following sources for their valuable tutorials and resources that helped me learn and build the projects in this repository:
-
simple-example
-
item-api
-
fastapi-crash-course
-
ml-with-fastapi
π‘A big thank you to these creators for sharing their knowledge and helping the FastAPI community grow!