eduardo-alvarez commited on
Commit
edf18ab
·
verified ·
1 Parent(s): 8342f96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -28
app.py CHANGED
@@ -35,6 +35,15 @@ with demo:
35
  gr.Markdown("""A special shout-out to the 🤗 [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
36
  team for generously sharing their code and best
37
  practices, ensuring that AI Developers have a valuable and enjoyable tool at their disposal.""")
 
 
 
 
 
 
 
 
 
38
 
39
  with gr.Accordion("Chat with Top Models on the Leaderboard Here 💬", open=False):
40
  # import pdb
@@ -227,34 +236,6 @@ with demo:
227
  citation =gr.Textbox(value = CITATION_TEXT,
228
  lines=6,
229
  label="Use the following to cite this content")
230
-
231
- import gradio as gr
232
- import socket
233
-
234
- def predict(text, request: gr.Request):
235
- client_ip = request.client.host
236
- local_ip = socket.gethostbyname(socket.gethostbyname(""))
237
- x_forwarded_for = request.headers.get('x-forwarded-for')
238
- headers = request.headers
239
- if x_forwarded_for:
240
- client_ip = x_forwarded_for
241
- print("client_ip", client_ip, text)
242
- print("x_forwarded_for", x_forwarded_for)
243
- return text, {"client_ip": client_ip,
244
- "local_ip": local_ip,
245
- "headers": headers}
246
-
247
-
248
- with gr.Blocks() as block:
249
- gr.Markdown("## Gradio get client IP")
250
- text = gr.Textbox(label="dummy input")
251
- output = gr.JSON({})
252
- btn = gr.Button("Test")
253
-
254
- btn.click(predict, inputs=[text], outputs=[text, output])
255
-
256
- block.queue()
257
- block.launch(share=False, server_name='0.0.0.0', show_api=True)
258
 
259
  gr.Markdown("""<div style="display: flex; justify-content: center;"> <p> Intel, the Intel logo and Gaudi are trademarks of Intel Corporation or its subsidiaries.
260
  *Other names and brands may be claimed as the property of others.
 
35
  gr.Markdown("""A special shout-out to the 🤗 [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
36
  team for generously sharing their code and best
37
  practices, ensuring that AI Developers have a valuable and enjoyable tool at their disposal.""")
38
+
39
+ client_ip = request.client.host
40
+ local_ip = socket.gethostbyname(socket.gethostbyname(""))
41
+ x_forwarded_for = request.headers.get('x-forwarded-for')
42
+ headers = request.headers
43
+ if x_forwarded_for:
44
+ client_ip = x_forwarded_for
45
+ gr.Markdown(f"client ip: {client_ip}")
46
+ gr.Markdown(f"info: {x_forwarded_for}")
47
 
48
  with gr.Accordion("Chat with Top Models on the Leaderboard Here 💬", open=False):
49
  # import pdb
 
236
  citation =gr.Textbox(value = CITATION_TEXT,
237
  lines=6,
238
  label="Use the following to cite this content")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
240
  gr.Markdown("""<div style="display: flex; justify-content: center;"> <p> Intel, the Intel logo and Gaudi are trademarks of Intel Corporation or its subsidiaries.
241
  *Other names and brands may be claimed as the property of others.