Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -676,6 +676,9 @@ def save_to_file(content, filename=None, prompt=None):
|
|
| 676 |
elif not filename.endswith('.txt'):
|
| 677 |
filename = f"{filename}_{generate_filename()}"
|
| 678 |
|
|
|
|
|
|
|
|
|
|
| 679 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 680 |
|
| 681 |
try:
|
|
@@ -692,6 +695,9 @@ def save_to_json(content, source_type, prompt, filename=None):
|
|
| 692 |
if filename is None:
|
| 693 |
filename = generate_filename(prefix=f"{source_type}_analysis", ext="json")
|
| 694 |
|
|
|
|
|
|
|
|
|
|
| 695 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 696 |
|
| 697 |
# Format the content from text to structured JSON
|
|
@@ -928,6 +934,9 @@ def save_to_html(content, source_type, filename=None):
|
|
| 928 |
if filename is None:
|
| 929 |
filename = generate_filename(prefix=f"{source_type}_analysis", ext="html")
|
| 930 |
|
|
|
|
|
|
|
|
|
|
| 931 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 932 |
|
| 933 |
try:
|
|
@@ -1582,6 +1591,8 @@ def main():
|
|
| 1582 |
# Function to read a saved file
|
| 1583 |
def read_saved_file(filename):
|
| 1584 |
try:
|
|
|
|
|
|
|
| 1585 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 1586 |
with open(filepath, 'r', encoding='utf-8') as f:
|
| 1587 |
return f.read()
|
|
@@ -1601,6 +1612,8 @@ def main():
|
|
| 1601 |
if not filename:
|
| 1602 |
return None
|
| 1603 |
try:
|
|
|
|
|
|
|
| 1604 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 1605 |
if not os.path.exists(filepath):
|
| 1606 |
return None
|
|
@@ -1619,6 +1632,8 @@ def main():
|
|
| 1619 |
return "Please enter a filename"
|
| 1620 |
|
| 1621 |
try:
|
|
|
|
|
|
|
| 1622 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 1623 |
if not os.path.exists(filepath):
|
| 1624 |
return "File not found"
|
|
|
|
| 676 |
elif not filename.endswith('.txt'):
|
| 677 |
filename = f"{filename}_{generate_filename()}"
|
| 678 |
|
| 679 |
+
# Ensure filename has no extra whitespace
|
| 680 |
+
filename = filename.strip()
|
| 681 |
+
|
| 682 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 683 |
|
| 684 |
try:
|
|
|
|
| 695 |
if filename is None:
|
| 696 |
filename = generate_filename(prefix=f"{source_type}_analysis", ext="json")
|
| 697 |
|
| 698 |
+
# Ensure filename has no extra whitespace
|
| 699 |
+
filename = filename.strip()
|
| 700 |
+
|
| 701 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 702 |
|
| 703 |
# Format the content from text to structured JSON
|
|
|
|
| 934 |
if filename is None:
|
| 935 |
filename = generate_filename(prefix=f"{source_type}_analysis", ext="html")
|
| 936 |
|
| 937 |
+
# Ensure filename has no extra whitespace
|
| 938 |
+
filename = filename.strip()
|
| 939 |
+
|
| 940 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 941 |
|
| 942 |
try:
|
|
|
|
| 1591 |
# Function to read a saved file
|
| 1592 |
def read_saved_file(filename):
|
| 1593 |
try:
|
| 1594 |
+
# Trim any whitespace from the filename
|
| 1595 |
+
filename = filename.strip()
|
| 1596 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 1597 |
with open(filepath, 'r', encoding='utf-8') as f:
|
| 1598 |
return f.read()
|
|
|
|
| 1612 |
if not filename:
|
| 1613 |
return None
|
| 1614 |
try:
|
| 1615 |
+
# Trim any whitespace from the filename
|
| 1616 |
+
filename = filename.strip()
|
| 1617 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 1618 |
if not os.path.exists(filepath):
|
| 1619 |
return None
|
|
|
|
| 1632 |
return "Please enter a filename"
|
| 1633 |
|
| 1634 |
try:
|
| 1635 |
+
# Trim any whitespace from the filename
|
| 1636 |
+
filename = filename.strip()
|
| 1637 |
filepath = os.path.join(OUTPUT_DIR, filename)
|
| 1638 |
if not os.path.exists(filepath):
|
| 1639 |
return "File not found"
|