rewrite routing to list

This commit is contained in:
2022-04-06 14:32:09 +02:00
parent d84027ac14
commit 10160bceed
3 changed files with 13 additions and 9 deletions
+4 -2
View File
@@ -19,9 +19,10 @@ email = input("Email-adres: ")
full_name = input("Volledige naam: ")
list_id = ""
user_cred = {"username": username, "password": password, "uuid": uuid}
user_cred = {"username": username, "password": password, "uuid": uuid}
user_info = {"uuid":uuid, "email": email, "name": full_name ,"listid": list_id}
stores_list = {"stores_name": ["Jumbo","AH","Boons","Aldi","Lidl"]}
item_list = {"stores_name" : 1}
if db.user_cred.find_one({"username": username}):
print("Username already exists\n")
@@ -31,3 +32,4 @@ else:
info_record = db.user_info.insert_one(user_info)
print("User created")
stores_record = db.stores_list.insert_many(stores_list)
+6 -5
View File
@@ -26,16 +26,17 @@ def login():
auth_user_id = db.user_cred.find_one({"username": username},{"uuid": 1})
if auth_user_id:
app.logger.info(auth_user_id)
return render_template("welcome.html", id=auth_user_id["uuid"])
return redirect(url_for("list", id=auth_user_id["uuid"]))
#return render_template("list.html", username=username)
else:
return render_template("404.html")
return redirect(url_for("not_found"))
else:
error = "Usernaam of wachtwoord onbekend, probeer opnieuw"
return render_template("login.html", error=error)
@app.route("/welcome/<id>", methods=['GET'])
def welcome(id):
print("Hello: ", id)
@app.route("/list/<id>", methods=['GET'])
def list(id):
return render_template("list.html", id=id)
@app.errorhandler(404)
def not_found(error):
@@ -1,14 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Welcome to groclist</title>
<title>Items on your list</title>
<meta name="viewpoint" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="container">
<h2>Welcome to GrocList<h2>
<br>
Hello userid: {{ userid }}
Hello {{ id }}
<p>Click <a href="/list/"{{ id }}>List</a> to view shopping list</p>
<p>Click <a href="/">here</a> to go home. </p>
</div>
</body>