broadfield-dev commited on
Commit
d775574
·
verified ·
1 Parent(s): 4210680

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -96,6 +96,14 @@ def generate_image(selected_service_name: str, secret_data_str: str, current_con
96
  logger.error(f"Image creation failed: {e}", exc_info=True)
97
  return None, None, f"❌ Error: {e}"
98
 
 
 
 
 
 
 
 
 
99
  # ==============================================================================
100
  # GRADIO INTERFACE
101
  # ==============================================================================
@@ -151,6 +159,26 @@ with gr.Blocks(theme=gr.themes.Soft(), title="KeyLock Image Creator") as demo:
151
  gr.Markdown("---")
152
  save_config_button = gr.Button("Save Current Configuration to File", variant="secondary")
153
  config_status_output = gr.Textbox(label="Configuration Status", interactive=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
  # --- Interactivity ---
156
 
 
96
  logger.error(f"Image creation failed: {e}", exc_info=True)
97
  return None, None, f"❌ Error: {e}"
98
 
99
+ def get_endpoints_json() -> str:
100
+ """Reads and returns the content of endpoints.json as a string."""
101
+ try:
102
+ with open("endpoints.json", "r") as f:
103
+ return f.read()
104
+ except Exception as e:
105
+ logger.error(f"Could not read endpoints.json: {e}")
106
+ raise gr.Error("Server could not read its endpoints.json configuration file.")
107
  # ==============================================================================
108
  # GRADIO INTERFACE
109
  # ==============================================================================
 
159
  gr.Markdown("---")
160
  save_config_button = gr.Button("Save Current Configuration to File", variant="secondary")
161
  config_status_output = gr.Textbox(label="Configuration Status", interactive=False)
162
+ with gr.Row(visible=False):
163
+ # Original API for creating images
164
+ api_secret_input = gr.Textbox()
165
+ api_pubkey_input = gr.Textbox()
166
+ api_image_output = gr.Image(type="pil")
167
+ gr.Interface(
168
+ fn=create_image_api,
169
+ inputs=[api_secret_input, api_pubkey_input],
170
+ outputs=api_image_output,
171
+ api_name="create_image"
172
+ )
173
+
174
+ # NEW API to get the endpoint list
175
+ api_get_endpoints_output = gr.Textbox()
176
+ gr.Interface(
177
+ fn=get_endpoints_json,
178
+ inputs=[],
179
+ outputs=api_get_endpoints_output,
180
+ api_name="get_endpoints" # This creates /run/get_endpoints
181
+ )
182
 
183
  # --- Interactivity ---
184