CSB261 commited on
Commit
ec086c7
โ€ข
1 Parent(s): 4e96c9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -1
app.py CHANGED
@@ -68,9 +68,46 @@ tab1 = gr.Interface(fn, inputs=image_upload, outputs=slider1, examples=[chameleo
68
  tab2 = gr.Interface(fn, inputs=url_input, outputs=slider2, examples=[url_example], api_name="text")
69
  tab3 = gr.Interface(process_file, inputs=image_file_upload, outputs=output_file, examples=["butterfly.jpg"], api_name="png")
70
 
71
- demo = gr.TabbedInterface(
72
  [tab1, tab2, tab3], ["Image Upload", "URL Input", "File Output"], title="Background Removal Tool"
73
  )
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  if __name__ == "__main__":
76
  demo.launch(show_error=True)
 
68
  tab2 = gr.Interface(fn, inputs=url_input, outputs=slider2, examples=[url_example], api_name="text")
69
  tab3 = gr.Interface(process_file, inputs=image_file_upload, outputs=output_file, examples=["butterfly.jpg"], api_name="png")
70
 
71
+ demo_tabs = gr.TabbedInterface(
72
  [tab1, tab2, tab3], ["Image Upload", "URL Input", "File Output"], title="Background Removal Tool"
73
  )
74
 
75
+ # ๋กœ๊ทธ์ธ ๊ด€๋ จ ์ฝ”๋“œ
76
+ def verify_credentials(username, password):
77
+ if username == "abc" and password == "1234":
78
+ return True, "Successfully logged in."
79
+ else:
80
+ return False, "Invalid username or password."
81
+
82
+ def login(username, password):
83
+ success, message = verify_credentials(username, password)
84
+ if success:
85
+ return gr.update(visible=False), gr.update(visible=True), gr.update(value=message)
86
+ else:
87
+ return gr.update(visible=True), gr.update(visible=False), gr.update(value=message)
88
+
89
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
90
+ with gr.Blocks() as demo:
91
+ # ๋กœ๊ทธ์ธ ์„น์…˜
92
+ with gr.Row() as login_row:
93
+ with gr.Column():
94
+ gr.Markdown("## Login")
95
+ username = gr.Textbox(label="Username")
96
+ password = gr.Textbox(label="Password", type="password")
97
+ login_button = gr.Button("Login")
98
+ login_message = gr.Textbox(label="Message", interactive=False, visible=False)
99
+
100
+ # ๋ฉ”์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„น์…˜ (์ดˆ๊ธฐ์—๋Š” ์ˆจ๊น€)
101
+ with gr.Row(visible=False) as main_app:
102
+ with gr.Column():
103
+ demo_tabs.render()
104
+
105
+ # ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ
106
+ login_button.click(
107
+ login,
108
+ inputs=[username, password],
109
+ outputs=[login_row, main_app, login_message]
110
+ )
111
+
112
  if __name__ == "__main__":
113
  demo.launch(show_error=True)