diff --git a/Backend/__pycache__/petfuc.cpython-311.pyc b/Backend/__pycache__/petfuc.cpython-311.pyc new file mode 100644 index 0000000..f26ccc6 Binary files /dev/null and b/Backend/__pycache__/petfuc.cpython-311.pyc differ diff --git a/Backend/__pycache__/userfuc.cpython-311.pyc b/Backend/__pycache__/userfuc.cpython-311.pyc new file mode 100644 index 0000000..a1a2b87 Binary files /dev/null and b/Backend/__pycache__/userfuc.cpython-311.pyc differ diff --git a/Backend/main.py b/Backend/main.py index 0728623..d9f1042 100644 --- a/Backend/main.py +++ b/Backend/main.py @@ -1,54 +1,106 @@ """ -This module provides functions for HTTP communication and -route functions +This module provides functions for HTTP communication and route functions. """ from flask import Flask, request, jsonify +from flasgger import Swagger from petfuc import get_random_pet from userfuc import add_user_faviorte, remove_user_faviorte, replace_user_location app = Flask(__name__) +Swagger(app) # Initialize Swagger -#Get Random Pet information - For homepage +# Get Random Pet information - For homepage @app.route("/Get_Random_pet", methods=["GET"]) def random_pet(): """ - Function to extract random pet information + Retrieve a random pet's information for the homepage. + --- + responses: + 200: + description: Returns random pet information successfully. + schema: + type: object + properties: + name: + type: string + example: 'Rex' + breed: + type: string + example: 'Dog' + age: + type: integer + example: 5 """ - return get_random_pet(), 200 # Return dog information + return get_random_pet(), 200 -# Faviortes route. add user faviorte pet to database +# Favorites route. Add user favorite pet to database @app.route("/Add_User_Faviorte", methods=["POST"]) def adduserfaviorte(): """ - Function to add user from database + Add a pet to the user's favorites in the database. + --- + parameters: + - in: body + name: pet + required: true + schema: + type: object + properties: + pet_id: + type: integer + example: 101 + responses: + 200: + description: Pet added to favorites successfully. """ json_data = request.get_json() - - # Api accesses database and append post json in database - #Retrun database with succses code return jsonify(add_user_faviorte(json_data)), 200 -# Un Faviote Route. remove user faviorte pet from there database +# Unfavorite Route. Remove user favorite pet from their database @app.route("/Remove_User_Faviorte", methods=["DELETE"]) def removeuserfaviorte(): """ - Function to remove user from database + Remove a pet from the user's favorites in the database. + --- + parameters: + - in: body + name: pet + required: true + schema: + type: object + properties: + pet_id: + type: integer + example: 101 + responses: + 200: + description: Pet removed from favorites successfully. """ json_data = request.get_json() + return jsonify(remove_user_faviorte(json_data)), 200 - # Api accesses database and append post json in database - #Retrun database with succses code - return jsonify(remove_user_faviorte(json_data)), 200 # return new user database - -# Change a Users account location +# Change a User's account location @app.route("/Change_User_Location", methods=["PUT"]) def replace_user_information(): """ - Function to change the location associated with - an account + Change the location associated with a user's account. + --- + parameters: + - in: body + name: location + required: true + schema: + type: object + properties: + new_location: + type: string + example: 'New York, NY' + responses: + 200: + description: User location updated successfully. """ - newlocation = request.get_json() # Get new location from post request - return jsonify(replace_user_location(newlocation)) # retrun user account info + newlocation = request.get_json() + return jsonify(replace_user_location(newlocation)), 200 if __name__ == "__main__": app.run(host="0.0.0.0", port=5000, debug=True)