ahmedghani commited on
Commit
eedad6f
Β·
1 Parent(s): 6445654

complete code added

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py CHANGED
@@ -252,6 +252,23 @@ def update_endpoint(
252
  else:
253
  return f"Something went wrong!, StatusCode:{response.status_code}, Error: {response.text}"
254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  with gr.Blocks() as interface:
256
  gr.Markdown("""
257
  #### Your πŸ€— Access Token <span style="color:red;">(Required)</span>
@@ -508,6 +525,23 @@ with gr.Blocks() as interface:
508
  interactive=False
509
  )
510
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  # Pricing Table
512
  with gr.Tab("Pricing Table"):
513
  gr.Markdown("""
@@ -613,4 +647,19 @@ with gr.Blocks() as interface:
613
  outputs=delete_status_txt
614
  )
615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
  interface.launch()
 
252
  else:
253
  return f"Something went wrong!, StatusCode:{response.status_code}, Error: {response.text}"
254
 
255
+ def get_endpoint_logs(
256
+ hf_token_input,
257
+ endpoint_name_input,
258
+ ):
259
+ response = requests.get(
260
+ f"https://api.endpoints.huggingface.cloud/endpoint/{endpoint_name_input}/logs",
261
+ headers = {
262
+ "Authorization": f"Bearer {hf_token_input.strip()}",
263
+ "Content-Type": "application/json",
264
+ })
265
+ if response.status_code == 401:
266
+ return "Invalid token or No logs found!"
267
+ elif response.status_code == 200:
268
+ return response.text
269
+ elif response.status_code == 404:
270
+ return f"Error: {response.text}"
271
+
272
  with gr.Blocks() as interface:
273
  gr.Markdown("""
274
  #### Your πŸ€— Access Token <span style="color:red;">(Required)</span>
 
525
  interactive=False
526
  )
527
 
528
+ # Endpoint logs
529
+ with gr.Tab("Endpoint Logs"):
530
+ gr.Markdown("""
531
+ ### Endpoint Logs
532
+ """)
533
+ endpoint_logs_load_button = gr.Button(value="Load Endpoints πŸ”ƒ")
534
+ endpoint_logs_selector = gr.Dropdown(
535
+ [],
536
+ value="",
537
+ show_label=False
538
+ )
539
+ endpoint_logs = gr.Textbox(
540
+ value="",
541
+ interactive=False
542
+ )
543
+ endpoint_logs_button = gr.Button(value="Get Logs")
544
+
545
  # Pricing Table
546
  with gr.Tab("Pricing Table"):
547
  gr.Markdown("""
 
647
  outputs=delete_status_txt
648
  )
649
 
650
+ # Endpoint Logs Tab Events
651
+ endpoint_logs_load_button.click(
652
+ get_all_endpoints,
653
+ inputs=[hf_token_input, gr.TextArea(value="logs", interactive=False, visible=False)],
654
+ outputs=endpoint_logs_selector
655
+ )
656
+ endpoint_logs_button.click(
657
+ get_endpoint_logs,
658
+ inputs=[
659
+ hf_token_input,
660
+ endpoint_logs_selector
661
+ ],
662
+ outputs=endpoint_logs
663
+ )
664
+
665
  interface.launch()