Skip to content

MohdSaif-1807/PythonAssignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Application with MongoDB Atlas Integration

This project demonstrate the use FlaskAPI with API endpoints, with a test suite.

Accessing the Application

In order to view docker image can visit the below link provided:

https://hub.docker.com/r/saif0786/python-assignment

In order to run the FastAPI application on the local system:

  1. we need to clone the repository with the command:
git clone 'https://github.com/MohdSaif-1807/PythonAssignment'
  1. Create a .env file and mongodb url with variable in the following way

    MONGO_URL = "<valid mongo url>"
    
  2. Also we have to Uncomment the below code from main.py to parse and insert data into MongoDB:

    parse_courses(courses)
    
  3. In order to start the FlaskAPI application we need to type the command as follows:

  fastapi dev main.py

Once we start the application, we can access the FastAPI application at:

http://localhost:8000

You can explore the API documentation and interact with the endpoints directly from your browser using FastAPI's interactive Swagger UI.

API Endpoints

  1. Get All Courses

    GET /fetch-all-courses/
    

    Query Parameters:

    • domain (optional): Filter courses by domain.

Screenshot to fetch all records:

Screenshot (3)

Screenshot to fetch records based on domain:

Screenshot (4)

  1. Get Course Overview

    GET /fetch-specific-record/{course_id}/
    

    Path Parameters:

    • course_id: The ID of the course to retrieve.

Screenshot to fetch specific course:

Screenshot (5)

  1. Get Chapter Information

    GET /fetch-specific-chapter-from-record/{chapter_id}/
    

    Path Parameters:

    • chapter_id: The ID of the chapter.

Screenshot to get specific chapter information:

Screenshot (6)

  1. Rate a Chapter

    POST /add-rating/{chapter_id}/
    

    Path Parameters:

    • chapter_id: The ID of the chapter.

    Request Body:

    {
      "rating_value": integer
    }

    screenshot to give ratings to a specific chapter:

    Screenshot (7)

Testing the Application

In order to run the Test script for API's we need to run the command as follows:

pytest test.py

screenshot for the result of the TestScript

Screenshot (8)

About

A FastAPI Application which demonstrate the use of API's

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published