rewrite routing to list
This commit is contained in:
+3
-1
@@ -21,7 +21,8 @@ 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}
|
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}):
|
if db.user_cred.find_one({"username": username}):
|
||||||
print("Username already exists\n")
|
print("Username already exists\n")
|
||||||
@@ -31,3 +32,4 @@ else:
|
|||||||
info_record = db.user_info.insert_one(user_info)
|
info_record = db.user_info.insert_one(user_info)
|
||||||
print("User created")
|
print("User created")
|
||||||
|
|
||||||
|
stores_record = db.stores_list.insert_many(stores_list)
|
||||||
|
|||||||
@@ -26,16 +26,17 @@ def login():
|
|||||||
auth_user_id = db.user_cred.find_one({"username": username},{"uuid": 1})
|
auth_user_id = db.user_cred.find_one({"username": username},{"uuid": 1})
|
||||||
if auth_user_id:
|
if auth_user_id:
|
||||||
app.logger.info(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:
|
else:
|
||||||
return render_template("404.html")
|
return redirect(url_for("not_found"))
|
||||||
else:
|
else:
|
||||||
error = "Usernaam of wachtwoord onbekend, probeer opnieuw"
|
error = "Usernaam of wachtwoord onbekend, probeer opnieuw"
|
||||||
return render_template("login.html", error=error)
|
return render_template("login.html", error=error)
|
||||||
|
|
||||||
@app.route("/welcome/<id>", methods=['GET'])
|
@app.route("/list/<id>", methods=['GET'])
|
||||||
def welcome(id):
|
def list(id):
|
||||||
print("Hello: ", id)
|
return render_template("list.html", id=id)
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def not_found(error):
|
def not_found(error):
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Welcome to groclist</title>
|
<title>Items on your list</title>
|
||||||
<meta name="viewpoint" content="width=device-width, initial-scale=1.0">
|
<meta name="viewpoint" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Welcome to GrocList<h2>
|
<h2>Welcome to GrocList<h2>
|
||||||
<br>
|
<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>
|
<p>Click <a href="/">here</a> to go home. </p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
Reference in New Issue
Block a user