fastapi dev main.pystAPI
Welcome to the Learn FastAPI repository! This is a structured learning resource designed to help you master FastAPI, the modern, high-performance web framework for Python, step by step. Whether you're a beginner or an experienced developer exploring FastAPI for the first time, this repository has something for you.
This repository is divided into well-organized sections that cover all essential aspects of FastAPI, from basic concepts to advanced topics. Each section includes detailed explanations, examples, and exercises to solidify your understanding.
The repository is structured as follows:
-
1. Basics:
- Setting up FastAPI.
- Writing your first FastAPI application.
-
2. Routing:
- Defining endpoints and handling requests.
- Using path and query parameters.
-
3. Data Models:
- Working with
Pydantic
for data validation. - Defining request and response models.
- Working with
-
4. Dependency Injection:
- Managing dependencies efficiently.
- Reusable components with
Depends
.
-
5. Authentication:
- Implementing OAuth2.
- Securing APIs with JWT tokens.
-
6. Advanced Topics:
- WebSockets for real-time communication.
- Background tasks for asynchronous processing.
- Middleware and custom exceptions.
Each topic is accompanied by practical examples to help you learn by doing.
Before you begin, make sure you have:
- Python 3.9 or higher installed.
- Basic familiarity with Python programming.
-
Clone this repository to your local machine:
git clone https://github.com/AZiyarati/FastAPI-Learning_Curve.git cd FastAPI-Learning_Curve
-
Switch to the desired branch for the specific exercise or topic:
git checkout <branch-name>
-
Install the required dependencies:
pip install -r requirements.txt
-
Start the FastAPI development server:
fastapi dev main.py
-
Open your browser and visit http://127.0.0.1:8000 to see the application running.
Each exercise or section is organized into a separate branch for easy access and cloning. Here are the key branches:
01-introduction
: Basics and motivation for using FastAPI.02-routing
: Setting up routes and handling requests.03-data-models
: Using Pydantic models for validation.04-dependencies
: Dependency injection and reusable components.05-authentication
: Implementing JWT and OAuth2.06-advanced
: Advanced topics like WebSockets and background tasks.
To work on a specific branch, simply switch to it using:
git checkout <branch-name>
Contributions are welcome! This repository is maintained by:
If you'd like to add examples, fix issues, or improve the content:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature-name
-
Commit your changes:
git commit -m "Add feature-name"
-
Push to your branch:
git push origin feature-name
-
Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Special thanks to the creators of FastAPI for building an amazing framework and providing extensive documentation. For more information, visit the FastAPI documentation.
Happy coding! 🎉