diff --git a/Backend/api.py b/Backend/api.py new file mode 100644 index 0000000..a72deb4 --- /dev/null +++ b/Backend/api.py @@ -0,0 +1,18 @@ +import requests +import json + +try: + wa = " http://192.168.1.102:5000/check" + id = int(input('Enter roll no: ')) + password = input('Enter password: ') + + data = {'id':id, "password":password} + res = requests.post(wa,json=json.dumps(data)) + print(res) + + data = res.json() + ans =data['msg'] + print(ans) + +except Exception as e: + print(e) \ No newline at end of file diff --git a/Backend/app.py b/Backend/app.py index 4c5d0c6..f50f96a 100644 --- a/Backend/app.py +++ b/Backend/app.py @@ -1,7 +1,8 @@ -from flask import Flask +from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy from flask_cors import CORS, cross_origin - +from sqlite3 import * +import json app = Flask(__name__) @@ -45,6 +46,30 @@ def __init__(self,phy,chem,maths,eng): def index(): return "Hello From Flask Here" +@app.route('/check', methods=['POST','GET']) +def check(): + + data = json.loads(request.get_json()) + id = data['id'] + password = data['password'] + con = None + try: + con = connect('student_results.db') + cursor = con.cursor() + cursor.execute("insert into StudentLoginModel (id, password) values ('%d','%s')" % (id,password)) + con.commit() + return jsonify({'msg': "Details are successfully stored in the database..!"}) + + except Exception as e: + con.rollback() + return jsonify({'msg': "There's some issue: " + str(e)}) + + finally: + if con is not None: + con.close() + + + if __name__ == '__main__': app.run(host="0.0.0.0", debug=True, port=5000) diff --git a/Backend/student_results.db b/Backend/student_results.db new file mode 100644 index 0000000..e69de29 diff --git a/student_results.db b/student_results.db index fcefea1..b3a8902 100644 Binary files a/student_results.db and b/student_results.db differ