Update app.py
Browse files
app.py
CHANGED
@@ -159,7 +159,7 @@ def save_endpoints(endpoints_list): json.dump(endpoints_list, open(ENDPOINTS_FIL
|
|
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:
|
162 |
-
all_servers_state = gr.State(load_endpoints)
|
163 |
active_server_state = gr.State({})
|
164 |
|
165 |
gr.Markdown("# π KeyLock Showcase")
|
@@ -196,7 +196,7 @@ with gr.Blocks(theme=theme, title="KeyLock Showcase") as demo:
|
|
196 |
gr.Markdown("## Embedded Server Details")
|
197 |
gr.Markdown("This Gradio app is also running its own KeyLock server. You can use its details to test the client.")
|
198 |
gr.Textbox(label="Embedded Server Status", value=KEYLOCK_STATUS_MESSAGE, interactive=False, lines=3)
|
199 |
-
gr.Code(label="Embedded Server Public Key", value=PUBLIC_KEY_PEM_STRING, language="
|
200 |
gr.JSON(label="Embedded Server Required Payload", value={k['key_name']: k['example'] for k in api_get_info()["required_payload_keys"]})
|
201 |
|
202 |
with gr.Accordion("Generate Image with Embedded Server", open=False):
|
@@ -210,8 +210,8 @@ with gr.Blocks(theme=theme, title="KeyLock Showcase") as demo:
|
|
210 |
output_private_key = gr.Textbox(lines=8, label="Generated Private Key", interactive=False, show_copy_button=True)
|
211 |
output_public_key = gr.Textbox(lines=8, label="Generated Public Key", interactive=False, show_copy_button=True)
|
212 |
|
213 |
-
def initialize_ui(
|
214 |
-
return gr.update(choices=[s['name'] for s in
|
215 |
|
216 |
def process_server_connection(server_data, all_servers):
|
217 |
placeholder = "\n".join([f"{k['key_name']}: {k['example']}" for k in server_data['info'].get('required_payload_keys', [])])
|
|
|
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:
|
162 |
+
all_servers_state = gr.State(value=load_endpoints())
|
163 |
active_server_state = gr.State({})
|
164 |
|
165 |
gr.Markdown("# π KeyLock Showcase")
|
|
|
196 |
gr.Markdown("## Embedded Server Details")
|
197 |
gr.Markdown("This Gradio app is also running its own KeyLock server. You can use its details to test the client.")
|
198 |
gr.Textbox(label="Embedded Server Status", value=KEYLOCK_STATUS_MESSAGE, interactive=False, lines=3)
|
199 |
+
gr.Code(label="Embedded Server Public Key", value=PUBLIC_KEY_PEM_STRING, language="pem")
|
200 |
gr.JSON(label="Embedded Server Required Payload", value={k['key_name']: k['example'] for k in api_get_info()["required_payload_keys"]})
|
201 |
|
202 |
with gr.Accordion("Generate Image with Embedded Server", open=False):
|
|
|
210 |
output_private_key = gr.Textbox(lines=8, label="Generated Private Key", interactive=False, show_copy_button=True)
|
211 |
output_public_key = gr.Textbox(lines=8, label="Generated Public Key", interactive=False, show_copy_button=True)
|
212 |
|
213 |
+
def initialize_ui(all_servers_list):
|
214 |
+
return gr.update(choices=[s['name'] for s in all_servers_list] if all_servers_list else [])
|
215 |
|
216 |
def process_server_connection(server_data, all_servers):
|
217 |
placeholder = "\n".join([f"{k['key_name']}: {k['example']}" for k in server_data['info'].get('required_payload_keys', [])])
|