mroccuper commited on
Commit
b3aa6d6
·
verified ·
1 Parent(s): ebbfcdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -11,9 +11,9 @@ TONE_OPTIONS = ["Friendly", "Humanized", "Engaging", "Funny", "Emotional"]
11
  # ---------------------------
12
  # Function to extract main content from HTML
13
  # ---------------------------
14
- def extract_main_content(html_file):
15
  try:
16
- soup = BeautifulSoup(html_file, "html.parser")
17
  article = soup.find("article") or soup.body
18
  text = article.get_text(separator="\n", strip=True) if article else ""
19
  print("[extract_main_content] Successfully extracted main content.")
@@ -80,7 +80,8 @@ def app_interface(html_file, tones, platform_choice, api_key):
80
  return "Please upload an HTML blog post."
81
 
82
  print("[app_interface] Reading HTML file...")
83
- html_content = html_file.read().decode("utf-8")
 
84
  main_text = extract_main_content(html_content)
85
  if not main_text:
86
  return "Couldn't extract content from file. Ensure it's a valid HTML blog post."
 
11
  # ---------------------------
12
  # Function to extract main content from HTML
13
  # ---------------------------
14
+ def extract_main_content(html_text):
15
  try:
16
+ soup = BeautifulSoup(html_text, "html.parser")
17
  article = soup.find("article") or soup.body
18
  text = article.get_text(separator="\n", strip=True) if article else ""
19
  print("[extract_main_content] Successfully extracted main content.")
 
80
  return "Please upload an HTML blog post."
81
 
82
  print("[app_interface] Reading HTML file...")
83
+ html_bytes = html_file.read()
84
+ html_content = html_bytes.decode("utf-8")
85
  main_text = extract_main_content(html_content)
86
  if not main_text:
87
  return "Couldn't extract content from file. Ensure it's a valid HTML blog post."