code: def login():
      """Log in a registered user by adding the user id to the session."""
      if request.method == "POST":
          username = request.form["username"]
          password = request.form["password"]
          db = get_db()
          error = None
          user = db.execute(
              "SELECT * FROM user WHERE username = ?", (username,)
          ).fetchone()
  
          if user is None:
              error = "Incorrect username."
          elif not check_password_hash(user["password"], password):
              error = "Incorrect password."
  
          if error is None:
              # store the user id in a new session and return to the index
              session.clear()
              session["user_id"] = user["id"]
              return redirect(url_for("index"))
  
          flash(error)
  
      return render_template("auth/login.html")
  
file_path: flask/examples/tutorial/flaskr/auth.py
imports: import functools
  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 session
  from flask import url_for
  from werkzeug.security import check_password_hash
  from werkzeug.security import generate_password_hash
  from .db import get_db
label_desc: Use image node_id 4 for calling a global function with example usage: login() and returns: render_template, redirect