Spaces:
Sleeping
Sleeping
Nikhil Singh
commited on
Commit
·
28ca0f2
1
Parent(s):
13ac7c2
Labels fix
Browse files
app.py
CHANGED
|
@@ -8,14 +8,13 @@ def accept_mail(name):
|
|
| 8 |
|
| 9 |
def clean_email(email):
|
| 10 |
soup = BeautifulSoup(email.body, 'html.parser')
|
| 11 |
-
|
| 12 |
for tag in soup.find_all(['style', 'link']):
|
| 13 |
tag.decompose()
|
| 14 |
-
|
| 15 |
cleaned_text = ' '.join(soup.get_text(separator=' ').split())
|
| 16 |
return cleaned_text
|
| 17 |
|
| 18 |
-
def present(
|
|
|
|
| 19 |
email_info = {
|
| 20 |
"Subject": email.subject,
|
| 21 |
"From": email.from_,
|
|
@@ -27,18 +26,28 @@ def present(email):
|
|
| 27 |
}
|
| 28 |
return [
|
| 29 |
email_info["Subject"],
|
| 30 |
-
email_info["From"],
|
| 31 |
-
email_info["To"],
|
| 32 |
email_info["Date"],
|
| 33 |
email_info["Message ID"],
|
| 34 |
-
email_info["Headers"],
|
| 35 |
-
email_info["Attachments"]
|
| 36 |
]
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
demo = gr.Interface(
|
| 39 |
fn=present,
|
| 40 |
inputs="text",
|
| 41 |
-
outputs=
|
| 42 |
title="Email Info",
|
| 43 |
description="Enter the email content below to view its details."
|
| 44 |
)
|
|
|
|
| 8 |
|
| 9 |
def clean_email(email):
|
| 10 |
soup = BeautifulSoup(email.body, 'html.parser')
|
|
|
|
| 11 |
for tag in soup.find_all(['style', 'link']):
|
| 12 |
tag.decompose()
|
|
|
|
| 13 |
cleaned_text = ' '.join(soup.get_text(separator=' ').split())
|
| 14 |
return cleaned_text
|
| 15 |
|
| 16 |
+
def present(email_content):
|
| 17 |
+
email = accept_mail(email_content)
|
| 18 |
email_info = {
|
| 19 |
"Subject": email.subject,
|
| 20 |
"From": email.from_,
|
|
|
|
| 26 |
}
|
| 27 |
return [
|
| 28 |
email_info["Subject"],
|
| 29 |
+
str(email_info["From"]), # Convert list to string for display
|
| 30 |
+
str(email_info["To"]), # Convert list to string for display
|
| 31 |
email_info["Date"],
|
| 32 |
email_info["Message ID"],
|
| 33 |
+
str(email_info["Headers"]), # Convert dictionary to string for display
|
| 34 |
+
str(email_info["Attachments"]) # Convert list to string for display
|
| 35 |
]
|
| 36 |
|
| 37 |
+
outputs = [
|
| 38 |
+
gr.outputs.Textbox(label="Subject"),
|
| 39 |
+
gr.outputs.Textbox(label="From"),
|
| 40 |
+
gr.outputs.Textbox(label="To"),
|
| 41 |
+
gr.outputs.Textbox(label="Date"),
|
| 42 |
+
gr.outputs.Textbox(label="Message ID"),
|
| 43 |
+
gr.outputs.Textbox(label="Headers"),
|
| 44 |
+
gr.outputs.Textbox(label="Attachments")
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
demo = gr.Interface(
|
| 48 |
fn=present,
|
| 49 |
inputs="text",
|
| 50 |
+
outputs=outputs,
|
| 51 |
title="Email Info",
|
| 52 |
description="Enter the email content below to view its details."
|
| 53 |
)
|