示例#1
0
def get():
    register_no = request.args.get('register_no')
    dob = request.args.get('dob')

    if register_no is None or dob is None:
        resp = make_response(json.dumps({'error': 'Request parameters are not in correct format.'}))
    else:
        if not check_regno(register_no) and not check_dob(dob):
            resp = make_response(json.dumps({'error': 'Invalid Register Number and Date of Birth.'}))
        elif not check_regno(register_no):
            resp = make_response(json.dumps({'error': 'Invalid Register Number.'}))
        elif not check_dob(dob):
            resp = make_response(json.dumps({'error': "Date of Birth is invalid."}))
        else:
            s = Scrapper(register_no, dob)
            json_data = s.get_json()
            resp = make_response(json_data)

    resp.mimetype = 'application/json'
    return resp