code: def get_post(id, check_author=True):
      """Get a post and its author by id.
  
      Checks that the id exists and optionally that the current user is
      the author.
  
      :param id: id of post to get
      :param check_author: require the current user to be the author
      :return: the post with author information
      :raise 404: if a post with the given id doesn't exist
      :raise 403: if the current user isn't the author
      """
      post = (
          get_db()
          .execute(
              "SELECT p.id, title, body, created, author_id, username"
              " FROM post p JOIN user u ON p.author_id = u.id"
              " WHERE p.id = ?",
              (id,),
          )
          .fetchone()
      )
  
      if post is None:
          abort(404, f"Post id {id} doesn't exist.")
  
      if check_author and post["author_id"] != g.user["id"]:
          abort(403)
  
      return post
  
file_path: flask/examples/tutorial/flaskr/blog.py
imports: from flask import Blueprint
  from flask import flash
  from flask import g
  from flask import redirect
  from flask import render_template
  from flask import request
  from flask import url_for
  from werkzeug.exceptions import abort
  from .auth import login_required
  from .db import get_db
label_desc: Use image node_id 2 for calling a global function with example usage: get_post(id, check_author) and returns: post