при запуске выдает ошибку выше
from flask import Flask, request, jsonify
app = Flask(__name__)
posts = []
@app.route('/create_post', methods=['POST'])
def create_post():
data = request.json
posts.append(data)
return jsonify({'message': 'Post created successfully'})
@app.route('/posts', methods=['GET'])
def get_posts():
return jsonify(posts)
@app.route('/add_comment/<int:post_id>', methods=['POST'])
def add_comment(post_id):
data = request.json
posts[post_id]['comments'].append(data)
return jsonify({'message': 'Comment added successfully'})
@app.route('/update_post/<int:post_id>', methods=['PUT'])
def update_post(post_id):
data = request.json
posts[post_id] = data
return jsonify({'message': 'Post updated successfully'})
if __name__ == '__main__':
app.run(debug=True)