diff --git a/app/__pycache__/routes.cpython-311.pyc b/app/__pycache__/routes.cpython-311.pyc index 6d68df8..c110b0b 100644 Binary files a/app/__pycache__/routes.cpython-311.pyc and b/app/__pycache__/routes.cpython-311.pyc differ diff --git a/app/routes.py b/app/routes.py index 9b05885..4b230cf 100644 --- a/app/routes.py +++ b/app/routes.py @@ -49,7 +49,7 @@ def get_courses(): for course in dt: df = df.append(course["attributes"], ignore_index=True) - df = df.drop("list_image_url", axis=1) + # df = df.drop("list_image_url", axis=1) if "next" not in next: break @@ -107,9 +107,41 @@ def get_people(): return "what what" -@app.route("/add_options") +@app.route("/add_options", methods=["POST"]) def add_options(): - return render_template("bulk_add.html", title="Bulk Add Learners") + array = [] + df = pd.DataFrame() + x = 0 + if request.method == "POST": + while True: + x += 1 + url = f"https://api.northpass.com/v2/groups?page={x}" + headers = {"accept": "application/json", "X-Api-Key": session["key"]} + response = requests.get(url, headers=headers) + data = response.text + df = pd.json_normalize(data) + print(df) + + # print(type(response)) + # print(response) + # jsonresponse = response.json() + # dt = jsonresponse["data"] + # next = jsonresponse["links"] + + for group in dt: + df = df.from_dict(group["attributes"], orient="index") + # df = df.append(group["id"], ignore_index=True) + # df = df.append(group["attributes"], ignore_index=True) + + if "next" not in next: + break + + print(df) + session["dfcsv"] = df.to_csv() + dfgroups = df.to_html(col_space=5) + return render_template( + "bulk_add.html", tables=dfgroups, titles="Bulk Add Learners" + ) @app.route("/bulk_add", methods=["GET", "POST"]) diff --git a/app/static/css/styles.css b/app/static/css/styles.css index e06c155..c104ab7 100644 --- a/app/static/css/styles.css +++ b/app/static/css/styles.css @@ -51,14 +51,14 @@ html { input, select { - width: 200px; - height: 25px; - margin: 2px; - --moz-box-sizing: border-box; - --webkit-box-sizing: border-box; - box-sizing: border-box; + width: 200px; + height: 25px; + margin: 2px; + --moz-box-sizing: border-box; + --webkit-box-sizing: border-box; + box-sizing: border-box; } - +/* .dataframe { font-size: 11pt; border-collapse: collapse; @@ -78,7 +78,7 @@ select { .dataframe tr:hover { background: #096F8E; cursor: pointer; -} +}*/ h1 { font-size: 4rem; diff --git a/app/templates/bulk_add.html b/app/templates/bulk_add.html index 7500594..c411780 100644 --- a/app/templates/bulk_add.html +++ b/app/templates/bulk_add.html @@ -3,22 +3,27 @@ {% block content %}
{{ error }} +
{{ error }}
{% endif %} - + +