Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,12 @@ import json
|
|
4 |
|
5 |
server_logic = AppServerLogic()
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
def process_image_and_display_payload(image):
|
8 |
if image is None:
|
9 |
return "Upload a KeyLock image to auto-fill credentials.", {}
|
@@ -38,35 +44,24 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
38 |
)
|
39 |
with gr.Row():
|
40 |
with gr.Column():
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
with gr.Column():
|
53 |
-
gr.Markdown("## Login")
|
54 |
-
user_name=gr.Textbox(label='User Name')
|
55 |
-
user_pass=gr.Textbox(label='Password', type='password')
|
56 |
-
login_btn=gr.Button("Login")
|
57 |
-
login_msg=gr.Markdown("### Enter user name and password")
|
58 |
-
gr.Markdown("## API Keys (Demo)")
|
59 |
-
user_GROQ=gr.Textbox(label='GROQ_API_KEY')
|
60 |
-
user_HF=gr.Textbox(label='HF_TOKEN')
|
61 |
-
user_OPENAI=gr.Textbox(label='OPENAI_API_KEY')
|
62 |
-
user_OPENROUTER=gr.Textbox(label='OPENROUTER_API_KEY')
|
63 |
|
64 |
with gr.Column():
|
65 |
keylock_builder = KeylockDecoderComponent(server_logic)
|
66 |
image_input, status_display = keylock_builder.build_ui()
|
67 |
|
68 |
output_json = gr.JSON(label="Decoded Payload")
|
69 |
-
|
|
|
70 |
image_input.upload(
|
71 |
fn=process_image_and_display_payload,
|
72 |
inputs=image_input,
|
|
|
4 |
|
5 |
server_logic = AppServerLogic()
|
6 |
|
7 |
+
example_db = {"USER":"TestUser","PASS":"TestPass"}
|
8 |
+
|
9 |
+
def login_fn(username,password):
|
10 |
+
if username==example_db.USER and password==example_db.PASS:
|
11 |
+
return gr.Update("### Logged in")
|
12 |
+
|
13 |
def process_image_and_display_payload(image):
|
14 |
if image is None:
|
15 |
return "Upload a KeyLock image to auto-fill credentials.", {}
|
|
|
44 |
)
|
45 |
with gr.Row():
|
46 |
with gr.Column():
|
47 |
+
gr.Markdown("## Login")
|
48 |
+
user_name=gr.Textbox(label='User Name')
|
49 |
+
user_pass=gr.Textbox(label='Password', type='password')
|
50 |
+
login_btn=gr.Button("Login")
|
51 |
+
login_msg=gr.Markdown("### Enter user name and password")
|
52 |
+
gr.Markdown("## API Keys (Demo)")
|
53 |
+
user_GROQ=gr.Textbox(label='GROQ_API_KEY')
|
54 |
+
user_HF=gr.Textbox(label='HF_TOKEN')
|
55 |
+
user_OPENAI=gr.Textbox(label='OPENAI_API_KEY')
|
56 |
+
user_OPENROUTER=gr.Textbox(label='OPENROUTER_API_KEY')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
with gr.Column():
|
59 |
keylock_builder = KeylockDecoderComponent(server_logic)
|
60 |
image_input, status_display = keylock_builder.build_ui()
|
61 |
|
62 |
output_json = gr.JSON(label="Decoded Payload")
|
63 |
+
|
64 |
+
login_btn.click(login_fn,[user_name,user_pass], login_msg)
|
65 |
image_input.upload(
|
66 |
fn=process_image_and_display_payload,
|
67 |
inputs=image_input,
|