from functools import wraps
from flask import flash, redirect, url_for, session
from app import views

def login_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash("Please login to continue.", "danger")
            return redirect(url_for("login"))
    return decorated_function
from functools import wraps
from flask import flash, redirect, url_for, session
from app import views

def login_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash("Please login to continue.", "danger")
            return redirect(url_for("login"))
    return decorated_function

def for_guests(f):
    @wraps(f)
    def decorated_function(*args, **kwrags):
        if not 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash("Invalid Action.", "danger")
            return redirect(url_for("dashboard"))
    return decorated_function
Create a decorator `for_guest` for access control on pages for guests.
Create a decorator `for_guest` for access control on pages for guests.

  from functools import wraps
  from flask import flash, redirect, url_for, session
  from app import views
  
  def login_required(f):
      @wraps(f)
      def decorated_function(*args, **kwargs):
          if 'logged_in' in session:
              return f(*args, **kwargs)
          else:
              flash("Please login to continue.", "danger")
              return redirect(url_for("login"))
      return decorated_function
+ 
+ def for_guests(f):
+     @wraps(f)
+     def decorated_function(*args, **kwrags):
+         if not 'logged_in' in session:
+             return f(*args, **kwargs)
+         else:
+             flash("Invalid Action.", "danger")
+             return redirect(url_for("dashboard"))
+     return decorated_function
Create a decorator `for_guest` for access control on pages for guests.
## Code Before:
from functools import wraps
from flask import flash, redirect, url_for, session
from app import views

def login_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash("Please login to continue.", "danger")
            return redirect(url_for("login"))
    return decorated_function
## Instruction:
Create a decorator `for_guest` for access control on pages for guests.
## Code After:
from functools import wraps
from flask import flash, redirect, url_for, session
from app import views

def login_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash("Please login to continue.", "danger")
            return redirect(url_for("login"))
    return decorated_function

def for_guests(f):
    @wraps(f)
    def decorated_function(*args, **kwrags):
        if not 'logged_in' in session:
            return f(*args, **kwargs)
        else:
            flash("Invalid Action.", "danger")
            return redirect(url_for("dashboard"))
    return decorated_function