Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bruhminister21 authored Aug 7, 2024
1 parent 101f6dd commit c184337
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
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():
return render_template('index.html')

@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)

0 comments on commit c184337

Please sign in to comment.