Flask : RuntimeError: Working outside of request context

Solution
from flask import Flask, render_template, request, session
app = Flask(__name__)
app.secret_key = 'change_this! and dont include it in questions!'
first_name = "nothing yet"  # this is the initial value when the app runs

@app.route('/', methods =["GET", "POST"])
def gfg():
    if request.method == "POST":
       global first_name  # this will use the global scope for this variable
       first_name = request.form.get("fname")  # this will update the global variable now!

       return "Your new name is " + first_name
    return "Your current name is " + first_name


if __name__ == '__main__':
    app.run(debug=True)