This project demonstrate the use FlaskAPI with API endpoints, with a test suite.
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:
- we need to clone the repository with the command:
git clone 'https://github.com/MohdSaif-1807/PythonAssignment'
-
Create a .env file and mongodb url with variable in the following way
MONGO_URL = "<valid mongo url>" -
Also we have to Uncomment the below code from main.py to parse and insert data into MongoDB:
parse_courses(courses) -
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.
-
Get All Courses
GET /fetch-all-courses/Query Parameters:
domain(optional): Filter courses by domain.
Screenshot to fetch all records:
Screenshot to fetch records based on domain:
-
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:
-
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:
-
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:
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





