|
|
|
import gradio as gr |
|
from gradio_keylock import KeylockDecoderComponent, AppServerLogic |
|
|
|
|
|
server_logic = AppServerLogic() |
|
|
|
with gr.Blocks(theme=gr.themes.Soft()) as demo: |
|
gr.Markdown("# Gradio KeyLock Component Demo") |
|
gr.Markdown( |
|
"Upload an image created by the component to see the decoded payload. " |
|
"You can also generate a new image below." |
|
) |
|
|
|
|
|
keylock_component = KeylockDecoderComponent(server_logic=server_logic) |
|
|
|
|
|
output_json = gr.JSON(label="Decoded Payload") |
|
|
|
|
|
def get_payload(result): |
|
if result and result.get("status") == "Success": |
|
return result.get("payload") |
|
return None |
|
|
|
|
|
keylock_component.change(fn=get_payload, inputs=keylock_component, outputs=output_json) |
|
|
|
demo.launch() |