<filename>backend/app.py
import functools

from flask import Flask, request, jsonify, abort

app = Flask(__name__)


def auth_required(fn):

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        if request.headers.get("Authorization") == "Bearer 12345":
            return fn(*args, **kwargs)
        else:
            abort(401)

    return wrapper


@app.route("/login/", methods=["POST"])
def login():
    if (
        request.json["username"] == "demo"
        and request.json["password"] == "<PASSWORD>"
    ):
        return jsonify({"token": "<PASSWORD>"})
    abort(400)


@app.route("/api/me/", methods=["GET"])
@auth_required
def user_details():
    return jsonify({"username": "demo", "email": "<EMAIL>"})


@app.route("/api/secure/", methods=["GET"])
@auth_required
def secure():
    return jsonify({"message": "this is fine"})

<filename>backend/app.py
import functools

from flask import Flask, request, jsonify, abort

app = Flask(__name__)


def auth_required(fn):

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        if request.headers.get("Authorization") == "Bearer 12345":
            return fn(*args, **kwargs)
        else:
            abort(401)

    return wrapper


@app.route("/login/", methods=["POST"])
def login():
    if (
        request.json["username"] == "demo"
        and request.json["password"] == "<PASSWORD>"
    ):
        return jsonify({"token": "<PASSWORD>"})
    abort(400)


@app.route("/api/me/", methods=["GET"])
@auth_required
def user_details():
    return jsonify({"username": "demo", "email": "<EMAIL>"})


@app.route("/api/secure/", methods=["GET"])
@auth_required
def secure():
    return jsonify({"message": "this is fine"})
