input: Write a function to create a basic CRUD API for the BlogPost model using Python and Flask. The API should include endpoints for creating a post, getting all posts, getting a single post, editing a post, and deleting a post. If the API is successfully set up, return True, otherwise return False.
  assert create_crud_api_for_blogpost() == True
output: 
  def create_crud_api_for_blogpost():
      from flask import Flask, request, jsonify
      app = Flask(__name__)
  
      blog_posts = []
  
      @app.route('/posts', methods=['POST'])
      def create_post():
          data = request.get_json()
          blog_posts.append(data)
          return jsonify(data), 201
  
      @app.route('/posts', methods=['GET'])
      def get_all_posts():
          return jsonify(blog_posts)
  
      @app.route('/posts/<int:post_id>', methods=['GET'])
      def get_single_post(post_id):
          if post_id < len(blog_posts):
              return jsonify(blog_posts[post_id])
          return jsonify({"error": "Post not found"}), 404
  
      @app.route('/posts/<int:post_id>', methods=['PUT'])
      def edit_post(post_id):
          if post_id < len(blog_posts):
              data = request.get_json()
              blog_posts[post_id].update(data)
              return jsonify(blog_posts[post_id])
          return jsonify({"error": "Post not found"}), 404
  
      @app.route('/posts/<int:post_id>', methods=['DELETE'])
      def delete_post(post_id):
          if post_id < len(blog_posts):
              del blog_posts[post_id]
              return jsonify({"result": True})
          return jsonify({"error": "Post not found"}), 404
  
      try:
          app.run(port=5000)
          return True
      except Exception as e:
          return False
  