SushantGautam commited on
Commit
445b2d0
·
1 Parent(s): acbca47

Refactor submissions data and add refresh API functionality in Gradio interface

Browse files
Files changed (1) hide show
  1. gradio_interface.py +15 -12
gradio_interface.py CHANGED
@@ -42,18 +42,8 @@ submissions = [
42
  timedelta(days=1)},
43
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
44
  timedelta(minutes=30)},
45
- {"user": "User2", "task": "task2", "submitted_time": datetime.now() -
46
- timedelta(days=1)},
47
- {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
48
- timedelta(minutes=30)},
49
- {"user": "User1", "task": "task1", "submitted_time": datetime.now() -
50
- timedelta(hours=1)},
51
  {"user": "User2", "task": "task2", "submitted_time": datetime.now() -
52
  timedelta(days=1)},
53
- {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
54
- timedelta(minutes=30)},
55
- {"user": "User2", "task": "task2", "submitted_time": datetime.now() -
56
- timedelta(days=1)},
57
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
58
  timedelta(minutes=30)},
59
  {"user": "User1", "task": "task1", "submitted_time": datetime.now() -
@@ -62,7 +52,7 @@ submissions = [
62
  timedelta(days=1)},
63
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
64
  timedelta(minutes=30)},
65
- {"user": "User2", "task": "task2", "submitted_time": datetime.now() -
66
  timedelta(days=1)},
67
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
68
  timedelta(minutes=30)},
@@ -72,7 +62,7 @@ submissions = [
72
  timedelta(days=1)},
73
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
74
  timedelta(minutes=30)},
75
- {"user": "User2", "task": "task2", "submitted_time": datetime.now() -
76
  timedelta(days=1)},
77
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
78
  timedelta(minutes=30)},
@@ -125,6 +115,10 @@ def add_submission(file):
125
  return f"Error: {str(e)}"
126
 
127
 
 
 
 
 
128
  # Define Gradio interface components
129
  output_table = gr.Dataframe(
130
  headers=["User", "Task", "Submitted Time"], value=display_submissions(), scale=5,)
@@ -152,5 +146,14 @@ with gr.Blocks(title="ImageCLEFmed-MEDVQA-GI-2025 Submissions") as demo:
152
  title="Upload Submissions",
153
  description="Upload a JSON file to add new submissions."
154
  )
 
 
 
 
 
 
 
 
 
155
 
156
  demo.launch()
 
42
  timedelta(days=1)},
43
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
44
  timedelta(minutes=30)},
 
 
 
 
 
 
45
  {"user": "User2", "task": "task2", "submitted_time": datetime.now() -
46
  timedelta(days=1)},
 
 
 
 
47
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
48
  timedelta(minutes=30)},
49
  {"user": "User1", "task": "task1", "submitted_time": datetime.now() -
 
52
  timedelta(days=1)},
53
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
54
  timedelta(minutes=30)},
55
+ {"user": "User2", "task": "task2", "submitted_time": datetime.now() -
56
  timedelta(days=1)},
57
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
58
  timedelta(minutes=30)},
 
62
  timedelta(days=1)},
63
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
64
  timedelta(minutes=30)},
65
+ {"user": "User2", "task": "task2", "submitted_time": datetime.now() -
66
  timedelta(days=1)},
67
  {"user": "User3", "task": "task1", "submitted_time": datetime.now() -
68
  timedelta(minutes=30)},
 
115
  return f"Error: {str(e)}"
116
 
117
 
118
+ def refresh_page():
119
+ return "API server is alive!"
120
+
121
+
122
  # Define Gradio interface components
123
  output_table = gr.Dataframe(
124
  headers=["User", "Task", "Submitted Time"], value=display_submissions(), scale=5,)
 
146
  title="Upload Submissions",
147
  description="Upload a JSON file to add new submissions."
148
  )
149
+ with gr.Tab("Refresh API", visible=False):
150
+ gr.Interface(
151
+ api_name="RefreshAPI",
152
+ fn=refresh_page,
153
+ inputs=[],
154
+ outputs="text",
155
+ title="Refresh API",
156
+ description="Hidden interface to refresh the API."
157
+ )
158
 
159
  demo.launch()