Spaces:
Sleeping
Sleeping
Nikhil Singh
commited on
Commit
·
3fd92e9
1
Parent(s):
1efe83d
revert
Browse files
app.py
CHANGED
|
@@ -2,8 +2,8 @@ import gradio as gr
|
|
| 2 |
from mailparser import parse_from_string
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
|
| 5 |
-
def accept_mail(
|
| 6 |
-
email = parse_from_string(
|
| 7 |
return email
|
| 8 |
|
| 9 |
def clean_email(email):
|
|
@@ -22,36 +22,26 @@ def present(email_content):
|
|
| 22 |
"To": email.to,
|
| 23 |
"Date": email.date,
|
| 24 |
"Message ID": email.message_id,
|
| 25 |
-
"Headers": email.headers,
|
| 26 |
-
"Attachments": email.attachments,
|
| 27 |
"Cleaned Body": cleaned_text
|
| 28 |
}
|
| 29 |
return [email_info[key] for key in email_info]
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
button = gr.Button("Process Email")
|
| 48 |
-
with gr.Column():
|
| 49 |
-
output_cleaned_text = gr.Textbox(label="Cleaned Email Body")
|
| 50 |
-
|
| 51 |
-
button.click(
|
| 52 |
-
present,
|
| 53 |
-
inputs=input_text,
|
| 54 |
-
outputs=output_texts + [output_cleaned_text]
|
| 55 |
-
)
|
| 56 |
-
|
| 57 |
demo.launch()
|
|
|
|
| 2 |
from mailparser import parse_from_string
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
|
| 5 |
+
def accept_mail(email_content):
|
| 6 |
+
email = parse_from_string(email_content)
|
| 7 |
return email
|
| 8 |
|
| 9 |
def clean_email(email):
|
|
|
|
| 22 |
"To": email.to,
|
| 23 |
"Date": email.date,
|
| 24 |
"Message ID": email.message_id,
|
| 25 |
+
"Headers": str(email.headers), # Convert dictionary to string for display
|
| 26 |
+
"Attachments": str(email.attachments), # Convert list to string for display
|
| 27 |
"Cleaned Body": cleaned_text
|
| 28 |
}
|
| 29 |
return [email_info[key] for key in email_info]
|
| 30 |
|
| 31 |
+
demo = gr.Interface(
|
| 32 |
+
fn=present,
|
| 33 |
+
inputs="text",
|
| 34 |
+
outputs=[
|
| 35 |
+
gr.components.Textbox(label="Subject"),
|
| 36 |
+
gr.components.Textbox(label="From"),
|
| 37 |
+
gr.components.Textbox(label="To"),
|
| 38 |
+
gr.components.Textbox(label="Date"),
|
| 39 |
+
gr.components.Textbox(label="Message ID"),
|
| 40 |
+
gr.components.Textbox(label="Headers"),
|
| 41 |
+
gr.components.Textbox(label="Attachments"),
|
| 42 |
+
gr.components.Textbox(label="Cleaned Body")
|
| 43 |
+
],
|
| 44 |
+
title="Email Info",
|
| 45 |
+
description="Enter the email content below to view its details."
|
| 46 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
demo.launch()
|