derek-thomas HF staff commited on
Commit
075c34d
1 Parent(s): ef5f9a3

Adding health endpoint

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  from pathlib import Path
 
3
 
4
  import gradio as gr
5
  from bs4 import BeautifulSoup
@@ -97,6 +98,13 @@ log files. I use gradio for `app` and map that to the open port of huggingface s
97
 
98
  The only communication between `app` and `main` is the log file.
99
  """
 
 
 
 
 
 
 
100
 
101
  with gr.Blocks() as demo:
102
  with gr.Tab("Application"):
@@ -115,6 +123,14 @@ with gr.Blocks() as demo:
115
  gr.Markdown(how_to_md)
116
  with gr.Tab("How does it work?"):
117
  gr.Markdown(how_does_it_work_md)
 
 
 
 
 
 
 
 
118
 
119
  if __name__ == '__main__':
120
  demo.queue().launch(server_name="0.0.0.0", show_error=True, server_port=7860)
 
1
  import os
2
  from pathlib import Path
3
+ from datetime import datetime
4
 
5
  import gradio as gr
6
  from bs4 import BeautifulSoup
 
98
 
99
  The only communication between `app` and `main` is the log file.
100
  """
101
+ def health(text):
102
+ # Get the current date and time
103
+ current_time = datetime.now()
104
+
105
+ # Print it in the format YYYY-MM-DD HH:MM:SS
106
+ print(current_time.strftime("%Y-%m-%d %H:%M:%S"))
107
+ return "Healthy"
108
 
109
  with gr.Blocks() as demo:
110
  with gr.Tab("Application"):
 
123
  gr.Markdown(how_to_md)
124
  with gr.Tab("How does it work?"):
125
  gr.Markdown(how_does_it_work_md)
126
+ with gr.Tab("Hidden"):
127
+ with gr.Column():
128
+ input_text = gr.Textbox(label="Input Text")
129
+ health_btn = gr.Button(value="Health")
130
+ with gr.Column():
131
+ output_text = gr.Textbox(label="Output Text")
132
+
133
+ health_btn.click(health, inputs=input_text, outputs=output_text, api_name="health")
134
 
135
  if __name__ == '__main__':
136
  demo.queue().launch(server_name="0.0.0.0", show_error=True, server_port=7860)