@app.route("/profile/<profile_id>/pinboard", methods=["GET", "POST"])
def pinboard_endpoint(profile_id):
    profile = get_user_for_response(profile_id, request)

    if request.method == "GET":
        board = Pinboard.query.filter_by(profile_id=profile.id).first()
        try:
            resp = board.contents
        except __HOLE__:
            abort_json(404, "user has no pinboard set yet.")

    elif request.method == "POST":
        abort_if_user_not_logged_in(profile)

        # debugging
        contents = request.json["contents"]
        product_pins = contents["one"]
        for (product_lable, tiid) in product_pins:
            current_user_must_own_tiid(tiid)
        resp = write_to_pinboard(profile.id, request.json["contents"])

    return json_resp_from_thing(resp)
dataset/ETHPy150Open Impactstory/total-impact-webapp/totalimpactwebapp/views.py/pinboard_endpoint