From c1843376a4372eb2931aab7403d07f1b3c43237a Mon Sep 17 00:00:00 2001 From: kekw <145754763+bruhminister21@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:44:02 +0530 Subject: [PATCH] Update app.py --- app.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index e232852..ff28089 100644 --- a/app.py +++ b/app.py @@ -1,11 +1,11 @@ -from flask import Flask, jsonify, request, render_template +from flask import Flask, request, jsonify, render_template from flask_cors import CORS app = Flask(__name__) -CORS(app) # Enable CORS for cross-origin requests +CORS(app) # Enable Cross-Origin Resource Sharing -# In-memory storage for comments (you can replace this with a database) -comments = [] +# In-memory database for demonstration purposes +comments_db = [] @app.route('/') def index(): @@ -13,13 +13,13 @@ def index(): @app.route('/comments', methods=['GET']) def get_comments(): - return jsonify(comments) + return jsonify(comments_db) @app.route('/comments', methods=['POST']) def add_comment(): - data = request.json - comments.append(data) - return jsonify(data), 201 + comment = request.json + comments_db.append(comment) + return jsonify({"message": "Comment added successfully!"}), 200 if __name__ == '__main__': app.run(debug=True)