raahinaez commited on
Commit
e56a034
·
verified ·
1 Parent(s): 262f72a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
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
- # File content is accessible via the 'file' attribute for 'NamedString' type
13
- file_content = file.read().decode("utf-8") # Decoding file data (assuming it's UTF-8 encoded)
14
- return json.loads(file_content) # Parse the JSON content
 
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