from flask import Flask, jsonify, render_template, url_for, request
app = Flask(__name__)

@app.route("/")
def index():
    return render_template('index.html')

@app.route("/login", methods=['POST'])
def login():
	params = request.get_json()
	print params
	return jsonify({'status':True})

@app.route("/signup", methods=['POST'])
def signup():
	params = request.get_json()
	print params
	return jsonify({'status':True})

@app.route("/logout", methods=['POST'])
def logout():
	return jsonify({'status':True})

if __name__ == '__main__':
    app.run(debug=True, threaded=True, host='0.0.0.0')
@@ -65,30 +65,698 @@
 est%0A
-app = Flask(__name__)%0A
+from flask_login import UserMixin, LoginManager, login_required, login_user, logout_user, current_user%0Afrom flask_mongoengine import MongoEngine, DoesNotExist%0Afrom settings import db,app%0Afrom models import User%0Aimport bcrypt%0A%0A# now get all the models from models.py ( this can be inside app.py)%0A# am just making it in models.py for readbility%0A%0Alogin_manager = LoginManager()%0Alogin_manager.init_app(app)%0A%0A%0A@login_manager.user_loader%0Adef load_user(user):%0A%09return User.objects.get(id=user)%0A%0A# ------------------------------------------------------------------------------------%0A# %09%09%09%09%09%09%09%09%09%09Flask Login ends%0A# ------------------------------------------------------------------------------------
 %0A@ap
@@ -781,20 +781,17 @@
 ndex():%0A
-    
+%09
 return r
@@ -907,32 +907,223 @@
 )%0A%09print params%0A
+%09try:%0A%09%09user = User.objects.get(username=params%5B'username'%5D)%0A%09%09if user.validate_login(user.password, params%5B'password'%5D):%0A%09%09%09user_obj = User.objects.get(id=user.id)%0A%09%09%09login_user(user_obj)%0A%09%09
 %09return jsonify(
@@ -1124,38 +1124,132 @@
 onify(%7B'status':
+ 
 True%7D)
+%0A%09except DoesNotExist:%0A%09%09return jsonify(%7B'status': False%7D)%0A%09return jsonify(%7B'status': False%7D)
 %0A%0A@app.route(%22/s
@@ -1331,16 +1331,343 @@
  params%0A
+%09try:%0A%09%09print 'try'%0A%09%09data = User.objects.get(username=params%5B'username'%5D)%0A%09%09return jsonify(%7B'status': False%7D)%0A%09except DoesNotExist:%0A%09%09print 'except'%0A%09%09hashed_pass = bcrypt.hashpw(params%5B'password'%5D, bcrypt.gensalt())%0A%09%09user_obj = User(username=params%5B'username'%5D)%0A%09%09user_obj.set_password(params%5B'password'%5D)%0A%09%09user_obj.save()%0A
 %09return 
@@ -1742,24 +1742,39 @@
 f logout():%0A
+%09logout_user()%0A
 %09return json
@@ -1826,12 +1826,9 @@
 _':%0A
-    
+%09
 app.

Update app with Login functions using the models