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 e007e4f commit 4cd6929
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""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
from utils import create_tables

# Initialize Flask app
app = Flask(__name__)
Expand All @@ -27,21 +26,7 @@ def init_db():
"""Create tables and add initial data if they don't exist."""
if not os.path.exists(DATABASE):
conn = get_db()
cursor = conn.cursor()

# Create the animals table
cursor.execute('''
CREATE TABLE IF NOT EXISTS animals (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
species TEXT NOT NULL,
breed TEXT,
age INTEGER,
personality TEXT,
image_path TEXT,
adoption_status TEXT DEFAULT 'Available'
)
''')
create_tables(conn)

# Insert initial pet data for testing
pets = [
Expand All @@ -53,7 +38,8 @@ def init_db():
('Bella', 'Dog', 'Bulldog', 2, 'Gentle', '/images/bella.jpg', 'Available')
]

# Insert data into the animals table
conn = get_db()
cursor = conn.cursor()
cursor.executemany('''
INSERT INTO animals (name, species, breed, age, personality, image_path, adoption_status)
VALUES (?, ?, ?, ?, ?, ?, ?)
Expand Down

0 comments on commit 4cd6929

Please sign in to comment.