This repository contains a simple FastAPI practice code to help you understand how FastAPI works and its basic functionalities.
FastAPI is a modern, fast, web framework for building APIs with Python 3.7+ based on standard Python type hints. It is designed to be easy to use, high-performance, and efficient. FastAPI allows you to quickly develop APIs with automatic validation, serialization, and documentation generation.
- Clone this repository to your local machine.
- Make sure you have Python 3.7+ installed on your system.
- Install the required dependencies using
pip install -r requirements.txt
. - Run the FastAPI application using
python app.py
. - Visit
http://localhost:8000/docs
in your browser to access the automatic API documentation and interact with the endpoints.
The project is structured as follows:
app.py
: This is the main FastAPI application file containing the API endpoints.requirements.txt
: Lists all the dependencies required for this project.
The FastAPI application provides the following endpoints:
GET /
: A welcome message indicating the API is running.GET /items/{item_id}
: Retrieves details of a specific item based on its ID.POST /items/
: Creates a new item with the provided data.PUT /items/{item_id}
: Updates an existing item based on its ID with the provided data.DELETE /items/{item_id}
: Deletes an item based on its ID.
If you find any issues or want to enhance the functionality, feel free to contribute by creating pull requests. Your contributions are welcome!
For more details on FastAPI, you can refer to the official documentation:
Let's get started with FastAPI and build powerful APIs with Python in no time! Happy coding!