From 8385162dd3e2371af24316d4c7eb3b2b86f0b866 Mon Sep 17 00:00:00 2001 From: Prince D Rusweka Rwabongoya Date: Wed, 23 Apr 2025 18:10:04 -0400 Subject: [PATCH] Update main.py --- backend/main.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/backend/main.py b/backend/main.py index 4a86eac..e4c21af 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,8 +1,12 @@ -from flask import Flask, jsonify, request -from flasgger import Swagger +"""This is the main Flask application for the pet adoption API.""" + + import sqlite3 import os +from flask import Flask, jsonify, request +from flasgger import Swagger + # Initialize Flask app app = Flask(__name__) @@ -80,7 +84,8 @@ def get_pets(): @app.route('/', methods=['GET']) def home(): """Home route to welcome users to the API.""" - return jsonify({'message': 'Welcome to the Pet API! Visit /apidocs for the Swagger documentation.'}) + return jsonify({'message': + 'Welcome to the Pet API! Visit /apidocs for the Swagger documentation.'}) @app.route('/api/pets/', methods=['GET']) def get_pet(pet_id): @@ -121,8 +126,11 @@ def add_pet(): cursor.execute(''' INSERT INTO animals (name, species, breed, age, personality, image_path, adoption_status) VALUES (?, ?, ?, ?, ?, ?, ?) - ''', (pet_data['name'], pet_data['species'], pet_data['breed'], pet_data['age'], - pet_data['personality'], pet_data.get('image_path', '/images/default.jpg'), 'Available')) + ''', (pet_data['name'], pet_data['species'], + pet_data['breed'], pet_data['age'], + pet_data['personality'], + pet_data.get('image_path', '/images/default.jpg'), + 'Available')) conn.commit() conn.close()