def page(): if request.method == "POST": email = request.form["email"] user = request.form["user"] passwd = request.form["passwd"] if passwd == "" or email == "" or user == "": flash("Du må fylle ut alle feltene", "error") return render_template("signup.html", email=email, user=user) query = db.signup(email, user, passwd) if "Error" not in query: login = logUserIn(email, passwd) if login[0]: return login[1] else: flash(login[1]) return login[2] else: print(query) flash("Brukernavnet eller mailen er allerede i bruk") return render_template("signup.html", email=email, username=user) else: if validateUser(): return redirect(url_for("user.page")) return render_template("signup.html")
def page(): if validateUser(): upload = uploads() return render_template("home.html", uploads=upload) # content burde være objekt som har alle funksjoner og attributer innebygd, kan accesse den inni HTML else: return render_template("home.html")
def page(): if validateUser(): session.pop("email", False) session.pop("user", False) session.pop("userId", False) session.pop("secret", False) return redirect(url_for("login.page"))
def page(): if request.method == "POST": if validateUser(): if validateImage(request): image = request.files["image"] filename = randomString() + "." + image.filename.split(".")[-1] query = db.fileUpload(filename, session["userId"]) if "Error" not in query: image.save(os.path.join("static\\uploads", filename)) return redirect(url_for("user.page")) # hvis bildet ikke ble validated flash("Det skjedde noe galt, prøv igjen") return render_template("upload.html") # hvis user ikke ble validated return (redirect(url_for("login.page"))) else: if validateUser(): return render_template("upload.html") return redirect(url_for("login.page"))
def page(): if request.method == "POST": email = request.form["email"] passwd = request.form["passwd"] if email != "" and passwd != "": login = logUserIn(email, passwd) if login[0]: return login[1] else: flash(login[1]) return login[2] else: flash("Du kan ikke ha tomt brukernavn eller passord") return render_template("login.html", email=email) else: if validateUser(): return redirect(url_for("user.page")) return render_template("login.html")
def page(): if validateUser(): uploadId = request.form["uploadId"] btnType = int(request.form["btnType"]) vote = db.getVote(session["userId"], uploadId) if "Error" not in vote: if len(vote) > 0: newVote = convertVote(btnType, int(vote[0][0])) if isinstance(newVote, int): query = db.updateVote(session["userId"], uploadId, newVote) else: query = db.delVote(session["userId"], uploadId) # reverse av vote else: query = db.insertVote(session["userId"], uploadId, btnType) if "Errror" not in query: return {"vote": "voted"} return {"Error": vote}
def settings(): if validateUser(): return render_template("user.html", settings=True) else: return redirect(url_for("login.page"))
def page(): if validateUser(): upload = uploads(session["userId"]) return render_template("user.html", uploads=upload) else: return redirect(url_for("login.page"))