2

I would like to render a specific Angular component after a serverside Python Flask process.

I would like to connect my user only if Password and Confirm_Password are the same. This check is done on the server for more security.

Here is my Flask code :

@app.route('/sign/', methods=['POST', 'GET'])
def register():
	if request.method == 'POST':
		users = mongo.db.users
		existing_user = users.find_one({'identifiant' : request.form['username']})
		if existing_user is None:
			if request.form['password']==request.form['password2']:
				hashpass = bcrypt.hashpw(request.form['password'].encode('utf-8'), bcrypt.gensalt())
				users.insert({'identifiant' : request.form['username'], 'email':request.form['email'], 'password' : hashpass})
			else:
				#return("Les mots de passes sont differents")
				return render_template("sign", message="Hello Flask!")
		else :
			return 'That username already exists!'
	return redirect(url_for('hello'))

If Password != Confirm_Password, I would like to render a specific component that says "Passwords are not the same". The issue is that I can't render a specific Angular component with Flask...

6
  • y are you trying to do this from python, you can do this in angular front end without even sending post request to flask Commented Apr 26, 2019 at 10:08
  • check this link Commented Apr 26, 2019 at 10:12
  • thanks for your msg ! I think that I don't understand this point. In my opinion, to create a full stack Single Page App, Angular = frontend, Flask = backend, MongoDB is my database. The routing is made by Angular. If I want to communicate with MongoDB I have to make POST and GET requests. If I want to make secure processes, I have to make it in the backend. But the communication between Flask and Angular is not working correclty, because I can't render a specific component in Flask. I don't know how to make it work. Commented Apr 26, 2019 at 10:16
  • My final question is : Is Angular.io a full stack app itself (front end + back end) or only the front end side ? Commented Apr 26, 2019 at 10:21
  • its on front end side you need somethings at back end, like MEAN stack or node js, or flask in your case which can interact with DB. but your problem of conforming password has no reason to connect to database, so that type of problems can be solved on front end its self Commented Apr 26, 2019 at 10:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.