Example #1
0
def target():
    """return info from url AJAX way"""
    target_url = request.args.get('target_url', 'None', type=str)
    contact_info = request.args.get('contact_info', 'None', type=str)
    if target_url != None:
        info = extract_profile(target_url, PROVIDERS)
        if info != None:
            # should we add contact info in db ?
            if contact_info != 'None':
                info.update({'contact_info': contact_info})
                if not info in db.all():
                    db.insert(info)
            # is this profile matching an item in db?
            matches = get_matching(info, db)
            if len(matches) > 0:
                return jsonify(profile_found=True,
                    contact_found=True,
                    target_url=target_url,
                    matches=matches)
            else:
                return jsonify(profile_found=True,
                    contact_found=False,
                    target_url=target_url,
                    matches=[info])
        else:
            return jsonify(profile_found=False,
                target_url=target_url)