Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created API function to return the result of the student #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
added return_result api in the app.py file
  • Loading branch information
yashneet-kalra committed Jan 5, 2022
commit e28ed7c70c45ea3932fb3762d2c2b4344372bf06
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/ExamResultGenerator.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions Backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)