Skip to content

Commit

Permalink
Merge pull request #35 from prateekmohanty63/loginFunc
Browse files Browse the repository at this point in the history
Feat(Login function) Login function implemented
  • Loading branch information
Ash515 committed Jan 29, 2022
2 parents b7e8092 + 5e42a84 commit c4c410a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Binary file modified Backend/__pycache__/app.cpython-39.pyc
Binary file not shown.
41 changes: 41 additions & 0 deletions Backend/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import sqlite3
from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
from sqlite3 import connect
import json

from sqlalchemy.orm import session
# from app import app
# from app import routes, models


app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:https:///student_results.db"
Expand Down Expand Up @@ -101,5 +106,41 @@ def addresult():
con.close()


@app.route('/login',methods=["POST","GET"])
def login():
r=""
msg=""

# data = json.loads(request.get_json())
if request.method=="POST":
username=request.form['username']
password=request.form['password']
# print(data["username"])
# username=1
# password="1234"
conn=sqlite3.connect("student_results.db")
c=conn.cursor()

c.execute("SELECT * FROM StudentLoginModel WHERE id='"+username+"' and password='"+password+"'")
r=c.fetchall()

for i in r:
if(username==i[0] and 'password'==i[1]):
session["logedin"]=True
session["username"]=username
return r;
else:
return "Invalid username and password"
else:
return "Please fill the complete form"









if __name__ == "__main__":
app.run(debug=True, port=5000)

0 comments on commit c4c410a

Please sign in to comment.