def see_edit(id): user = get_model().read(id) if request.method == 'POST': data = request.form.to_dict(flat=True) user = get_model().update(data, id) print("crud.py line 148") print(data) return redirect(url_for('.view', id=user['id'])) return render_template("signup.html", action="Edit", user=user)
def see(id): user = get_model().read(id) # print(user) print("User details are : crud.py:11") print(user) # print(")))))))))))") return render_template("user.html", users=user)
def view(): token = request.args.get('page_token', None) if token: token = token.encode('utf-8') users, next_page_token = get_model().list1(cursor=token) return render_template("view.html", users=users, next_page_token=next_page_token)
def login(): error = None if request.method == 'POST': user = get_model().nemail(str(request.form['email'])) if request.form['email'] == user['email'] and request.form[ 'password'] == user['password']: if user['admin'] == 'yes': return redirect(url_for('crud.view')) else: return render_template('validuser.html', user=user['email']) else: return render_template('form.html')
def signup(): # print(request.method) if request.method == 'POST': data = request.form.to_dict(flat=True) user = get_model().create(data) # print(user) url = "https://www.google.com/recaptcha/api/siteverify" cap_res = data.get("g-recaptcha-response") params = { 'secret': '6LdUGpIUAAAAAO2ASyVLPqRIYBVDWoeNVXj1ljgm', 'response': cap_res } res = requests.post(url, params=params) if res.json()['success']: return redirect(url_for('crud.form')) return render_template("signup.html", action="Signup", user={})
def delete(id): get_model().delete(id) return redirect(url_for('.view'))