gnumanth commited on
Commit
5a69f4d
·
verified ·
1 Parent(s): 21931b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -30
app.py CHANGED
@@ -86,25 +86,17 @@ async def process_input(input_text, uploaded_file=None):
86
  except Exception as e:
87
  return f"Error processing input: {str(e)}"
88
 
89
- # Custom CSS for drag-and-drop styling
90
- custom_css = """
91
- .upload-box {
92
- border: 2px dashed #ccc !important;
93
- border-radius: 8px !important;
94
- padding: 20px !important;
95
- text-align: center !important;
96
- transition: all 0.3s ease !important;
97
- }
98
- .upload-box:hover {
99
- border-color: #666 !important;
100
- background-color: rgba(0, 0, 0, 0.05) !important;
101
- }
102
- """
103
 
104
  # Create Gradio interface with drag-and-drop
105
- with gr.Blocks(css=custom_css) as iface:
106
- gr.Markdown("# Text Summarization Tool")
107
- gr.Markdown("Enter a URL, paste text, or drag & drop a file to get a summary.")
 
 
 
 
108
 
109
  with gr.Row():
110
  input_text = gr.Textbox(
@@ -121,25 +113,20 @@ with gr.Blocks(css=custom_css) as iface:
121
  ".html", ".htm", ".xml", ".json"
122
  ],
123
  file_count="single",
124
- scale=2,
125
- elem_classes=["upload-box"]
126
  )
127
 
128
  with gr.Row():
129
  submit_btn = gr.Button("Summarize", variant="primary")
130
  clear_btn = gr.Button("Clear")
131
 
132
- output_text = gr.Textbox(label="Summary", lines=10)
133
-
134
- # Event handlers for drag and drop using Gradio's event system
135
- file_upload.upload(
136
- fn=lambda: None,
137
- inputs=None,
138
- outputs=None,
139
- _js="() => {document.querySelector('.upload-box').classList.remove('dragover');}"
140
  )
141
 
142
- # Set up event handlers for the buttons
143
  submit_btn.click(
144
  fn=process_input,
145
  inputs=[input_text, file_upload],
@@ -147,8 +134,7 @@ with gr.Blocks(css=custom_css) as iface:
147
  )
148
 
149
  clear_btn.click(
150
- fn=lambda: (None, None, ""),
151
- inputs=None,
152
  outputs=[input_text, file_upload, output_text]
153
  )
154
 
@@ -160,3 +146,6 @@ with gr.Blocks(css=custom_css) as iface:
160
  ],
161
  inputs=input_text
162
  )
 
 
 
 
86
  except Exception as e:
87
  return f"Error processing input: {str(e)}"
88
 
89
+ def clear_inputs():
90
+ return ["", None, ""]
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  # Create Gradio interface with drag-and-drop
93
+ with gr.Blocks(theme=gr.themes.Soft()) as iface:
94
+ gr.Markdown(
95
+ """
96
+ # Text Summarization Tool
97
+ Enter a URL, paste text, or drag & drop a file to get a summary.
98
+ """
99
+ )
100
 
101
  with gr.Row():
102
  input_text = gr.Textbox(
 
113
  ".html", ".htm", ".xml", ".json"
114
  ],
115
  file_count="single",
116
+ scale=2
 
117
  )
118
 
119
  with gr.Row():
120
  submit_btn = gr.Button("Summarize", variant="primary")
121
  clear_btn = gr.Button("Clear")
122
 
123
+ output_text = gr.Textbox(
124
+ label="Summary",
125
+ lines=10,
126
+ show_copy_button=True
 
 
 
 
127
  )
128
 
129
+ # Set up event handlers
130
  submit_btn.click(
131
  fn=process_input,
132
  inputs=[input_text, file_upload],
 
134
  )
135
 
136
  clear_btn.click(
137
+ fn=clear_inputs,
 
138
  outputs=[input_text, file_upload, output_text]
139
  )
140
 
 
146
  ],
147
  inputs=input_text
148
  )
149
+
150
+ if __name__ == "__main__":
151
+ iface.launch()