satpalsr commited on
Commit
126eb71
·
1 Parent(s): da1d74c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -22
app.py CHANGED
@@ -1,27 +1,15 @@
1
  import gradio as gr
2
- import os
3
 
4
- auth_value = False
 
 
 
5
 
6
- def echo(name, request: gr.Request):
7
- global auth_value
8
- if request:
9
- if dict(request.headers)['origin'] in os.environ["ORIGIN"]:
10
- auth_value = True
11
- print("Request headers dictionary:", request.headers)
12
- print("IP address:", request.client.host)
13
- return str(request.headers), str(request.client.host)
14
 
15
- def verify_auth(username, password, request: gr.Request):
16
- global auth_value
17
- if dict(request.headers)['origin'] in os.environ["ORIGIN"]:
18
- auth_value = True
19
- return True
20
- elif username == "admin" and password == "admin":
21
- auth_value = True
22
- return True
23
- else:
24
- return False
25
-
26
 
27
- io = gr.Interface(echo, "textbox", ["textbox", "textbox"]).launch(auth=verify_auth)
 
1
  import gradio as gr
 
2
 
3
+ def get_msg(name, request: gr.Request):
4
+ if dict(request.headers)['origin'] in os.environ["ORIGIN"]:
5
+ return "Working"
6
+ return "Hello " + name + "!"
7
 
8
+ with gr.Blocks() as demo:
 
 
 
 
 
 
 
9
 
10
+ input = gr.Textbox(label="Prompt", elem_id="textbox")
11
+ output = gr.Textbox(label="Output", elem_id="textbox")
12
+ button = gr.Button(value="Make Magic", elem_id="button")
13
+ button.click(get_msg, inputs=[input], outputs=[output])
 
 
 
 
 
 
 
14
 
15
+ demo.launch()