broadfield-dev commited on
Commit
23129f7
·
verified ·
1 Parent(s): adedb69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -154,8 +154,17 @@ def api_decode_and_auth(image_base64_string: str) -> dict:
154
  except Exception as e:
155
  return {"status": "Error", "message": f"Decryption/Processing Failed: {e}", "details": {}}
156
 
157
- def load_endpoints(): return json.load(open(ENDPOINTS_FILE)) if os.path.exists(ENDPOINTS_FILE) else []
158
- def save_endpoints(endpoints_list): json.dump(endpoints_list, open(ENDPOINTS_FILE, 'w'), indent=2)
 
 
 
 
 
 
 
 
 
159
 
160
  theme = gr.themes.Soft(primary_hue="sky", secondary_hue="blue", neutral_hue="slate")
161
  with gr.Blocks(theme=theme, title="KeyLock Showcase") as demo:
@@ -250,7 +259,13 @@ with gr.Blocks(theme=theme, title="KeyLock Showcase") as demo:
250
  return updates
251
  except Exception as e:
252
  gr.Error(f"Connection Failed: {e}")
253
- return {}
 
 
 
 
 
 
254
 
255
  def client_generate_image_wrapper(active_server, payload_str, overlay, base_img, progress=gr.Progress(track_tqdm=True)):
256
  if not active_server: raise gr.Error("Not connected to a server.")
 
154
  except Exception as e:
155
  return {"status": "Error", "message": f"Decryption/Processing Failed: {e}", "details": {}}
156
 
157
+ def load_endpoints():
158
+ try:
159
+ if os.path.exists(ENDPOINTS_FILE):
160
+ with open(ENDPOINTS_FILE, 'r') as f:
161
+ return json.load(f)
162
+ except (FileNotFoundError, json.JSONDecodeError):
163
+ pass
164
+ return []
165
+ def save_endpoints(endpoints_list):
166
+ with open(ENDPOINTS_FILE, 'w') as f:
167
+ json.dump(endpoints_list, f, indent=2)
168
 
169
  theme = gr.themes.Soft(primary_hue="sky", secondary_hue="blue", neutral_hue="slate")
170
  with gr.Blocks(theme=theme, title="KeyLock Showcase") as demo:
 
259
  return updates
260
  except Exception as e:
261
  gr.Error(f"Connection Failed: {e}")
262
+ return {
263
+ active_server_state: gr.update(),
264
+ client_status_display: gr.update(),
265
+ client_payload_input: gr.update(),
266
+ all_servers_state: gr.update(),
267
+ saved_servers_dropdown: gr.update()
268
+ }
269
 
270
  def client_generate_image_wrapper(active_server, payload_str, overlay, base_img, progress=gr.Progress(track_tqdm=True)):
271
  if not active_server: raise gr.Error("Not connected to a server.")