diff options
| author | Tim Keller <tjkeller.xyz> | 2025-05-11 00:20:08 -0500 |
|---|---|---|
| committer | Tim Keller <tjkeller.xyz> | 2025-05-11 00:20:08 -0500 |
| commit | 31f1940ec8c4aba6a0c21b20eff9657d5d11cf80 (patch) | |
| tree | c4c3aaac22d65a78b48ac5e0173a3b28b7ebbb23 /flaskapi.py | |
| parent | 8afd27d113d20f924df73456374153397039e1ba (diff) | |
| download | immich-frame-31f1940ec8c4aba6a0c21b20eff9657d5d11cf80.tar.xz immich-frame-31f1940ec8c4aba6a0c21b20eff9657d5d11cf80.zip | |
albums thumbnails endpoint and albums endpoint
Diffstat (limited to 'flaskapi.py')
| -rw-r--r-- | flaskapi.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/flaskapi.py b/flaskapi.py index 29cea7e..0791016 100644 --- a/flaskapi.py +++ b/flaskapi.py @@ -1,4 +1,5 @@ -from flask import Flask, Blueprint, request, send_from_directory +from flask import Flask, Blueprint, request, send_from_directory, send_file, abort +from flask_cors import CORS app = Flask(__name__, static_folder="static/dist", static_url_path="/") @@ -10,6 +11,7 @@ def home(): return send_from_directory("static/public", "index.html") api = Blueprint("api", __name__) +CORS(api, origins="*") # For debugging TODO remove later @api.route("/seek") def seek(): @@ -24,4 +26,22 @@ def seek(): "imageIndex": pd.current_texture_index, } +@api.route("/albums/get") +def get_albums(): + ic = app.config["immich_connector"] + keys = [ "albumName", "albumThumbnailAssetId", "id", "startDate", "endDate", "assetCount", "shared", ] + return [{ + key: album[key] for key in keys + } for album in ic.load_all_albums() ] + +@api.route("/albums/thumb/<key>") +def get_album_thumb(key): + # TODO ensure getting actual album thumb + ic = app.config["immich_connector"] + image_data, mimetype = ic.load_image(key, size="thumbnail") + if image_data is None: + abort(400) + return send_file(image_data, mimetype=mimetype) + + app.register_blueprint(api, url_prefix="/api") |
