def verify(request, response): url = request['content']['apiUrl'][0] header = {'Authorization': ''.join(request['content']['authHeader'])} data = requests.get(url, headers=header).text data_dict = ast.literal_eval(data) phone_num = data_dict['phone_number'] if redis_server.sismember('all_users', phone_num): result = 'success' else: result = 'failure' content = {'status': result, 'user': phone_num} server.add_session(request, response, content) server.send_json_handler(request, response, content)
def verify(request, response): url = request['content']['apiUrl'][0] header = {'Authorization': ''.join(request['content']['authHeader'])} data = requests.get(url, headers=header).text data_dict = ast.literal_eval(data) phone_num = data_dict['phone_number'] if redis_server.sismember('all_users', phone_num): result = 'success' else: result = 'failure' content = {'status': result, 'user': phone_num} server.add_session(request, content) server.send_json_handler(request, response, content)
def showQuestion(request, response): # print("\n\n\nrequest",request['content']) data = db.show_Quest_pyExam() # htmlcode = makeQuestionBlocks(data) # json_data = json.dumps(dict(data)) # json_data = json.dumps(data) # print(json_data) # json_obj = json.loads(json_data) # global score # data1 = json.loads(json_data) # htmlcode = """<html> # <head> # <title>Python Proficiency Test</title> # </head> # <body> # %s<br> # <br> # <form action="/testPython" method="POST"> # <input type="radio" name="Opt" value=1 checked>%s<br> # <input type="radio" name="Opt" value=2>%s<br> # <input type="radio" name="Opt" value=3>%s<br> # <input type="radio" name="Opt" value=4>%s<br> # <br> # <button type='submit'>Submit</button> # </form> # </body> # </html>""" %(data['Question'],data['AnsOpt1'],data['AnsOpt2'],data['AnsOpt3'],data['AnsOpt4']) return server.send_json_handler(request, response, data)
def showQuestion(request, response): global data data = db.show_Quest_pyExam() qno_list = [] que_list = [] for i in data: que_dict = {} for j in i: if j != 'Answer' and j != 'Score': que_dict[j] = i[j] if j == 'QNo': qno_list.append(i[j]) que_list.append(que_dict) db.track_session(qno_list, request) return server.send_json_handler(request, response, que_list)
def showQuestion(request, response): global data data = db.show_Quest_pyExam() return server.send_json_handler(request, response, data)