https://github.com/mohdsaif-1807/pythonassignment
A FastAPI Application which demonstrate the use of API's
https://github.com/mohdsaif-1807/pythonassignment
api api-rest fastapi pytest python test-suite
Last synced: 4 months ago
JSON representation
A FastAPI Application which demonstrate the use of API's
- Host: GitHub
- URL: https://github.com/mohdsaif-1807/pythonassignment
- Owner: MohdSaif-1807
- Created: 2024-08-20T03:27:21.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-08-20T11:35:35.000Z (11 months ago)
- Last Synced: 2025-01-06T10:13:39.659Z (6 months ago)
- Topics: api, api-rest, fastapi, pytest, python, test-suite
- Language: Python
- Homepage: https://hub.docker.com/r/saif0786/python-assignment
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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'2. Create a .env file and mongodb url with variable in the following way
```
MONGO_URL = ""
```
3. Also we have to Uncomment the below code from main.py to parse and insert data into MongoDB:
```
parse_courses(courses)
```
4. 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 to fetch records based on domain:**
2. **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:**

3. **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:**
4. **Rate a Chapter**
```
POST /add-rating/{chapter_id}/
```**Path Parameters:**
- `chapter_id`: The ID of the chapter.**Request Body:**
```json
{
"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**