input: Write a function to create 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. The function should return the Flask app object.
  def create_blog_crud_api():
    from flask import Flask, jsonify, request
    from flask_sqlalchemy import SQLAlchemy
    
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
    db = SQLAlchemy(app)
    
    class BlogPost(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      title = db.Column(db.String(200))
      content = db.Column(db.Text)
    
      def serialize(self):
        return {'id': self.id, 'title': self.title, 'content': self.content}
    
    @app.route('/post', methods=['POST'])
    def create_post():
      data = request.get_json()
      post = BlogPost(title=data['title'], content=data['content'])
      db.session.add(post)
      db.session.commit()
      return jsonify(post.serialize())
    
    @app.route('/posts', methods=['GET'])
    def get_posts():
      posts = BlogPost.query.all()
      return jsonify([post.serialize() for post in posts])
    
    @app.route('/post/<id>', methods=['GET'])
    def get_post(id):
      post = BlogPost.query.filter_by(id=id).first()
      return jsonify(post.serialize())
    
    @app.route('/post/<id>', methods=['PUT'])
    def edit_post(id):
      data = request.get_json()
      post = BlogPost.query.filter_by(id=id).first()
      post.title = data['title']
      post.content = data['content']
      db.session.commit()
      return jsonify(post.serialize())
    
    @app.route('/post/<id>', methods=['DELETE'])
    def delete_post(id):
      post = BlogPost.query.filter_by(id=id).first()
      db.session.delete(post)
      db.session.commit()
      return jsonify({ 'message' : 'Post deleted' })
    
    return app
  
  assert create_blog_crud_api() is not None
  assert create_blog_crud_api().config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///test.db'
  assert create_blog_crud_api().url_map.bind('', '/').match('post')[0] == 'post'
  assert create_blog_crud_api().url_map.bind('', '/').match('posts')[0] == 'posts'
  assert create_blog_crud_api().url_map.bind('', '/').match('post/1')[0] == 'post'
  assert create_blog_crud_api().url_map.bind('', '/').match('post/1', method='PUT')[0] == 'post'
  assert create_blog_crud_api().url_map.bind('', '/').match('post/1', method='DELETE')[0] == 'post'
output: def create_blog_crud_api():
    from flask import Flask, jsonify, request
    from flask_sqlalchemy import SQLAlchemy
    
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
    db = SQLAlchemy(app)
    
    class BlogPost(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      title = db.Column(db.String(200))
      content = db.Column(db.Text)
    
      def serialize(self):
        return {'id': self.id, 'title': self.title, 'content': self.content}
    
    @app.route('/post', methods=['POST'])
    def create_post():
      data = request.get_json()
      post = BlogPost(title=data['title'], content=data['content'])
      db.session.add(post)
      db.session.commit()
      return jsonify(post.serialize())
    
    @app.route('/posts', methods=['GET'])
    def get_posts():
      posts = BlogPost.query.all()
      return jsonify([post.serialize() for post in posts])
    
    @app.route('/post/<id>', methods=['GET'])
    def get_post(id):
      post = BlogPost.query.filter_by(id=id).first()
      return jsonify(post.serialize())
    
    @app.route('/post/<id>', methods=['PUT'])
    def edit_post(id):
      data = request.get_json()
      post = BlogPost.query.filter_by(id=id).first()
      post.title = data['title']
      post.content = data['content']
      db.session.commit()
      return jsonify(post.serialize())
    
    @app.route('/post/<id>', methods=['DELETE'])
    def delete_post(id):
      post = BlogPost.query.filter_by(id=id).first()
      db.session.delete(post)
      db.session.commit()
      return jsonify({ 'message' : 'Post deleted' })
    
    return app