Skip to content

Commit

Permalink
api function to implement registration
Browse files Browse the repository at this point in the history
  • Loading branch information
dilroseR committed Aug 9, 2021
1 parent 3cb1af9 commit 54ae8af
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
18 changes: 18 additions & 0 deletions Backend/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import requests
import json

try:
wa = " http:https://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)
29 changes: 27 additions & 2 deletions Backend/app.py
Original file line number Diff line number Diff line change
@@ -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__)
Expand Down Expand Up @@ -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)

Empty file added Backend/student_results.db
Empty file.
Binary file modified student_results.db
Binary file not shown.

0 comments on commit 54ae8af

Please sign in to comment.