input: Write a function that creates a basic CRUD API for the BlogPost model using Python/Flask. The API should include endpoints for creating a post, getting all posts, getting a single post, editing a post, and deleting a post.
  assert create_post({'title': 'First Post', 'content': 'This is the first post content'})==<BlogPost 'First Post'>
  assert get_posts()==[{'id': 1, 'title': 'First Post', 'content': 'This is the first post content'}]
  assert get_post(1)=={'id': 1, 'title': 'First Post', 'content': 'This is the first post content'}
  assert edit_post(1, {'title': 'Updated Post', 'content': 'This is the updated post content'})=={'id': 1, 'title': 'Updated Post', 'content': 'This is the updated post content'}
  assert delete_post(1)=={'message': 'Post deleted'}
output: 
  from flask import Flask, request, jsonify
  
  app = Flask(__name__)
  posts = []
  post_id_counter = 1
  
  class BlogPost:
      def __init__(self, title, content):
          self.id = post_id_counter
          self.title = title
          self.content = content
          global post_id_counter
          post_id_counter += 1
  
      def to_dict(self):
          return {'id': self.id, 'title': self.title, 'content': self.content}
  
      def __repr__(self):
          return f"<BlogPost '{self.title}'>"
  
  @app.route('/posts', methods=['POST'])
  def create_post(data=None):
      if data is None:
          data = request.json
      title = data['title']
      content = data['content']
      new_post = BlogPost(title, content)
      posts.append(new_post)
      return repr(new_post)
  
  @app.route('/posts', methods=['GET'])
  def get_posts():
      return jsonify([post.to_dict() for post in posts])
  
  @app.route('/posts/<int:post_id>', methods=['GET'])
  def get_post(post_id):
      post = next((post for post in posts if post.id == post_id), None)
      if post:
          return jsonify(post.to_dict())
      return jsonify({'error': 'Post not found'}), 404
  
  @app.route('/posts/<int:post_id>', methods=['PUT'])
  def edit_post(post_id, data=None):
      if data is None:
          data = request.json
      post = next((post for post in posts if post.id == post_id), None)
      if post:
          post.title = data.get('title', post.title)
          post.content = data.get('content', post.content)
          return jsonify(post.to_dict())
      return jsonify({'error': 'Post not found'}), 404
  
  @app.route('/posts/<int:post_id>', methods=['DELETE'])
  def delete_post(post_id):
      global posts
      posts = [post for post in posts if post.id != post_id]
      return jsonify({'message': 'Post deleted'})
  