From aa8c3028f0adce5b37121a66dc72e4d507a2b1db Mon Sep 17 00:00:00 2001 From: yashneet Date: Wed, 5 Jan 2022 01:03:30 +0530 Subject: [PATCH 1/3] corrected SignIn page redirection --- Frontend/{Student_Login.html => SignIn.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Frontend/{Student_Login.html => SignIn.html} (100%) diff --git a/Frontend/Student_Login.html b/Frontend/SignIn.html similarity index 100% rename from Frontend/Student_Login.html rename to Frontend/SignIn.html From e28ed7c70c45ea3932fb3762d2c2b4344372bf06 Mon Sep 17 00:00:00 2001 From: yashneet Date: Wed, 5 Jan 2022 18:10:33 +0530 Subject: [PATCH 2/3] added return_result api in the app.py file --- .idea/.gitignore | 3 ++ .idea/ExamResultGenerator.iml | 12 ++++++ .idea/inspectionProfiles/Project_Default.xml | 14 +++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/misc.xml | 7 ++++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ Backend/app.py | 41 +++++++++++++++++++ 8 files changed, 97 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/ExamResultGenerator.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/ExamResultGenerator.iml b/.idea/ExamResultGenerator.iml new file mode 100644 index 0000000..8b8c395 --- /dev/null +++ b/.idea/ExamResultGenerator.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..0d1d82d --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b7ea289 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b1b7616 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Backend/app.py b/Backend/app.py index 538d52f..b739ceb 100644 --- a/Backend/app.py +++ b/Backend/app.py @@ -101,5 +101,46 @@ def addresult(): con.close() +@app.route("/return_result", methods=['POST']) +def return_result(): + if request.method == 'GET': + return jsonify({"msg": "Use 'POST' method for this API."}) + + data = json.loads(request.get_json()) + student_id = data["id"] + user_type = data["type"] + + if user_type.lower() != 'student': + return jsonify({"msg": "Invalid user type"}) + + con = None + try: + con = connect("student_results.db") + cursor = con.cursor() + cursor.execute("SELECT * FROM StoreModel WHERE rno = '%d'" % student_id) + data = cursor.fetchall() + + if not data: + return jsonify({"msg": "Marks details not uploaded yet."}) + + return jsonify( + { + "id": data[0], + "sub1": data[1], + "sub2": data[2], + "sub3": data[3], + "sub4": data[4] + } + ) + + 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(debug=True, port=5000) From bb003e97484ce65eeccfc80bbf1878eafabdf9a0 Mon Sep 17 00:00:00 2001 From: yashneet Date: Wed, 5 Jan 2022 19:41:38 +0530 Subject: [PATCH 3/3] added return_result.py file for the api --- Backend/app.py | 13 +++++++------ Backend/return_result.py | 26 ++++++++++++++++++++++++++ Backend/student_results.db | Bin 0 -> 20480 bytes 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 Backend/return_result.py diff --git a/Backend/app.py b/Backend/app.py index b739ceb..ce80816 100644 --- a/Backend/app.py +++ b/Backend/app.py @@ -7,6 +7,7 @@ app = Flask(__name__) app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///student_results.db" +app.config["JSON_SORT_KEYS"] = False db = SQLAlchemy(app) CORS(app) @@ -115,7 +116,7 @@ def return_result(): con = None try: - con = connect("student_results.db") + con = connect('student_results.db') cursor = con.cursor() cursor.execute("SELECT * FROM StoreModel WHERE rno = '%d'" % student_id) data = cursor.fetchall() @@ -125,11 +126,11 @@ def return_result(): return jsonify( { - "id": data[0], - "sub1": data[1], - "sub2": data[2], - "sub3": data[3], - "sub4": data[4] + "id": data[0][0], + "phy": data[0][1], + "chem": data[0][2], + "maths": data[0][3], + "eng": data[0][4] } ) diff --git a/Backend/return_result.py b/Backend/return_result.py new file mode 100644 index 0000000..6e60c4a --- /dev/null +++ b/Backend/return_result.py @@ -0,0 +1,26 @@ +import requests +import json + + +def return_result(): + try: + wa = "http://127.0.0.1:5000/return_result" + student_id = int(input("Enter id: ")) + user_type = input("Enter the user type: ").lower() + + data = { + "id": student_id, + "type": user_type + } + + res = requests.post(wa, json=json.dumps(data)) + print(res) + data = res.json() + ans = data + print(ans) + + except Exception as e: + print(e) + + +return_result() diff --git a/Backend/student_results.db b/Backend/student_results.db index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..115d7490d9835438985a1012ca15011a02d209ab 100644 GIT binary patch literal 20480 zcmeI%L5tHs6bJA(nWQy#+wmerM3`P=7Z%HIFCMK+*-KS)S8(@I(-a zj?UI1b|!1ASgqIDWOv@{C