This is a FastAPI application for managing user registration and retrieval. It allows users to register with their basic information along with a profile picture and retrieve user details by their ID.
-
Clone the repository:
git clone https://github.com/Cozyamy/FastAPI_UserDetails_Upload.git
-
Install the dependencies:
poetry shell
poetry install
Run the FastAPI application:
uvicorn main:app --reloadThe application will start on http://127.0.0.1:8000.
Access the API documentation by navigating to /docs or /redoc after running the application.
- Method: POST
- URL:
/register - Description: Register a new user with basic information and a profile picture.
- Parameters:
name(str): The user's name.age(int): The user's age.gender(str): The user's gender.ismarried(bool): The user's marital status.profile_picture(file): The user's profile picture.
- Response: Returns a message along with the newly created user.
- Errors: HTTP 400 if a user with the same name already exists.
- Method: GET
- URL:
/users/{user_id} - Description: Retrieve a user by their ID from the database.
- Parameters:
user_id(int): The ID of the user to retrieve.
- Response: Returns the user object corresponding to the user ID.
- Errors: HTTP 404 if the user is not found.
- Register a new user by making a POST request to
/register. - Retrieve a user by their ID using a GET request to
/users/{user_id}.