Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,10 @@ from io import BytesIO # For saving the PDF to memory
|
|
| 9 |
PAGE_WIDTH, PAGE_HEIGHT = letter
|
| 10 |
|
| 11 |
def load_json_from_file(file):
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
def generate_pdf(data):
|
| 17 |
buffer = BytesIO() # Create an in-memory file-like object to hold the PDF
|
|
|
|
| 9 |
PAGE_WIDTH, PAGE_HEIGHT = letter
|
| 10 |
|
| 11 |
def load_json_from_file(file):
|
| 12 |
+
# Gradio file input 'file' is a NamedString object
|
| 13 |
+
# Access the file content as bytes via 'file.data'
|
| 14 |
+
file_content = file.data.decode("utf-8") # Decode file bytes to string
|
| 15 |
+
return json.loads(file_content) # Parse the string into a Python dictionary
|
| 16 |
|
| 17 |
def generate_pdf(data):
|
| 18 |
buffer = BytesIO() # Create an in-memory file-like object to hold the PDF
|