diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2025-06-16 21:58:13 -0500 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2025-06-16 21:58:13 -0500 |
| commit | c5465f7ceed37f1ba6575248e1035e1430e78921 (patch) | |
| tree | d8d49d0b716f7188ffe2c27b4ca92361905215d2 | |
| parent | b8df4605b42d9a61bb4ae4731efabbdc38166063 (diff) | |
| download | immich-frame-c5465f7ceed37f1ba6575248e1035e1430e78921.tar.xz immich-frame-c5465f7ceed37f1ba6575248e1035e1430e78921.zip | |
config route and fix config saving/creation
| -rw-r--r-- | flaskapi.py | 6 | ||||
| -rw-r--r-- | manager.py | 2 | ||||
| -rw-r--r-- | settings.py | 6 |
3 files changed, 10 insertions, 4 deletions
diff --git a/flaskapi.py b/flaskapi.py index 45616ec..bb670a2 100644 --- a/flaskapi.py +++ b/flaskapi.py @@ -1,4 +1,4 @@ -from flask import Flask, Blueprint, request, send_from_directory, send_file, abort, redirect +from flask import Flask, Blueprint, request, send_from_directory, send_file, abort, redirect, jsonify from flask_socketio import SocketIO, emit from flask_cors import CORS @@ -62,5 +62,9 @@ def immich_redirect(path): def config_update(): return { "success": PixMan().update_config(request.json) } +@api.route("/config") +def config(): + return jsonify(PixMan().config) + app.register_blueprint(api, url_prefix="/api") @@ -49,7 +49,7 @@ class PixMan: signal.signal(signal.SIGINT, PixMan.handle_sigint) self.configfile = configfile - config = Config.load(self.configfile) if os.path.exists(self.configfile) else Config(file=self.configfile) + config = Config.load(self.configfile) if os.path.exists(self.configfile) else Config() self.init_web(host, port) self.update_config(config) diff --git a/settings.py b/settings.py index 43cb024..f11e930 100644 --- a/settings.py +++ b/settings.py @@ -28,12 +28,14 @@ class Config: def __post_init__(self): self.album_lists = [ AlbumList(*a) for a in self.album_lists ] + def __dict__(self): + return asdict(self) + @classmethod def load(cls, filepath): with open(filepath, "r") as fp: return cls(**json.load(fp)) def save(self, filepath): - data = asdict(self) with open(filepath, "w") as fp: - json.dump(data, fp, indent=2) + json.dump(asdict(self), fp, indent=2) |
