diff options
| author | user@node5.net <user@node5.net> | 2025-04-21 23:07:43 +0200 |
|---|---|---|
| committer | user@node5.net <user@node5.net> | 2025-04-21 23:07:43 +0200 |
| commit | d5f5e9af4a382be34592e93d34ee75408f3b2924 (patch) | |
| tree | 5cede7141a09c747edcd047055d4bf97fc41ba4c /src/main.py | |
| parent | 3fb9ee7fc744fdde3f76e78dfcfc996e71fe172f (diff) | |
Diffstat (limited to 'src/main.py')
| -rw-r--r-- | src/main.py | 31 |
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}') - |
