summaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.py')
-rw-r--r--src/main.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/main.py b/src/main.py
index a3e6b11..6dae322 100644
--- a/src/main.py
+++ b/src/main.py
@@ -11,10 +11,6 @@ import geopy.distance
app = flask.Flask(__name__)
-pic_root_path = 'src/static/pics/mine'
-
-pics = os.listdir(pic_root_path)
-
def decimal_coords(coords, ref):
decimal_degrees = coords[0] + coords[1] / 60 + coords[2] / 3600
if ref == "S" or ref =='W' :
@@ -89,6 +85,23 @@ def game():
return flask.render_template('game.html')
+
+pic_root_path = 'src/static/pics/mine'
+pics_original = os.listdir(pic_root_path)
+pics = []
+
+# Check if all images have GPS coordinates on application start
+for pic in pics_original:
+ img_path = os.path.join(pic_root_path, pic)
+ try:
+ exif = get_exif(img_path)
+ correct_coordinates = image_coordinates(exif)
+ pics.append(pic)
+ except Exception as ex:
+ print(f'Error loading GPS coordinates for: {img_path}')
+ raise ex
+
+
with closing(sqlite3.connect("guess_where.db")) as connection:
with closing(connection.cursor()) as cursor:
rows = cursor.execute("""
@@ -102,13 +115,3 @@ with closing(sqlite3.connect("guess_where.db")) as connection:
)
""").fetchall()
-
-
-# Check if all images have GPS coordinates on application start
-for pic in pics:
- img_path = os.path.join(pic_root_path, pic)
- try:
- correct_coordinates = image_coordinates(img_path)
- except Exception as ex:
- print(f'Error loading GPS coordinates for: {img_path}')
-