Example #1
0
 def get(self):
     parser = reqparse.RequestParser()
     parser.add_argument('photo_id', type=str, required=True,
                         help='Photo UUID to retrieve')
     parser.add_argument('include_data_uri', type=bool, required=False,
                         default=True, help='Photo UUID to retrieve')
     args = parser.parse_args()
     photo_id = args["photo_id"]
     include_data_uri = args["include_data_uri"]
     if photo_id:
         faces = get_user_faces(
             photo_id,
             exclude=["user_agent", "user_ip"]
         )
         photo_filename = "{}.png".format(photo_id)
         image_data_uri = get_file_remote(photo_filename,
                                          data_uri=include_data_uri)
         if faces:
             return {
                 "faces": faces,
                 "message": "OK",
                 "image_data_uri": image_data_uri,
                 "image_id": photo_id,
             }
     return {
         "faces": [],
         "message": "Invalid photo id",
         "image_data_uri": "",
         "image_id": ""
     }
Example #2
0
def view_home(photo_id=None):
    photo_url = None
    if not photo_id:
        photo_id = ""
    else:
        user_faces = get_user_faces(photo_id)
        if user_faces:
            photo_url = user_faces[0]['face_url']
    return render_template(
        'home.html',
        photo_id=photo_id,
        photo_url=photo_url,
    )