Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pdr21001 authored Apr 23, 2025
1 parent c7b51af commit 8385162
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down Expand Up @@ -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/<int:pet_id>', methods=['GET'])
def get_pet(pet_id):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 8385162

Please sign in to comment.