def register(): logger.info("Entered register method") form = RegisterForm(request.form) if request.method == 'POST' and form.validate(): email = form.email.data username = form.username.data password = sha256_crypt.encrypt(str(form.password.data)) data = { "email": form.email.data, "username": form.username.data, "password": sha256_crypt.encrypt(str(form.password.data)) } data = json.dumps(data) logger.info("Received form data") logger.info("Generating token") token = jwt.encode({}, app.config['SECRET_KEY']) token = token.decode('UTF-8') headers = {'access-token': token, 'content-type': 'application/json'} url = 'http://edureka-1630729118.us-east-1.elb.amazonaws.com:5002/register' response = requests.post(url, data=data, headers=headers) logger.info("Response from Register: {}".format(response.status_code)) if response.status_code is 200: flash('You are now registered and can login', 'success') return redirect(url_for('index')) return render_template('register.html', form=form)
def cek_register(): form = RegisterForm(request.form) voters = None if request.method == 'GET': voters = evote.search_voters_by_name('%') elif request.method == 'POST' and form.validate(): voters = evote.search_voters_by_name(request.form.get('name')) return render_template('cek_register.html', form=form, voters=voters)
def register(): logger.info("Entered register method") form = RegisterForm(request.form) if request.method == 'POST' and form.validate(): email = form.email.data username = form.username.data password = sha256_crypt.encrypt(str(form.password.data)) data = { "email": form.email.data, "username": form.username.data, "password": sha256_crypt.encrypt(str(form.password.data)) } data = json.dumps(data) logger.info("Received form data") headers = {'content-type': 'application/json'} url = 'http://user:5002/register' response = requests.post(url, data=data, headers=headers) logger.info("Response from Register: {}".format(response.status_code)) if response.status_code is 200: flash('You are now registered and can login', 'success') return redirect(url_for('index')) return render_template('register.html', form=form)