broadfield commited on
Commit
6c6fe07
·
verified ·
1 Parent(s): 1c93b3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -136,7 +136,13 @@ def parse_json(inp):
136
  if type(inp)==type(""):
137
  lines=""
138
  if "```" in inp:
139
- tog=False
 
 
 
 
 
 
140
  cnt=0
141
  for line in inp.split("\n"):
142
  if tog==True:
@@ -147,11 +153,11 @@ def parse_json(inp):
147
  if cnt==1:
148
  tog = True
149
  elif cnt==2:
150
- tog = False
151
  print("Extracted Lines")
152
- print(lines)
153
- out_json=eval(lines)
154
  try:
 
155
  out1=str(out_json['filename'])
156
  out2=str(out_json['filecontent'])
157
  return out1,out2
 
136
  if type(inp)==type(""):
137
  lines=""
138
  if "```" in inp:
139
+ start = string.find("```json") + 1 # Find index after the start character
140
+ end = string.find("```", start) # Find index of end character from the start index
141
+ if start >= 0 and end >= 0:
142
+ json1= string[start:end] # Slice the string between start and end
143
+ else:
144
+ json1="NONE" # Return None if characters not found
145
+ '''tog=False
146
  cnt=0
147
  for line in inp.split("\n"):
148
  if tog==True:
 
153
  if cnt==1:
154
  tog = True
155
  elif cnt==2:
156
+ tog = False'''
157
  print("Extracted Lines")
158
+ print(json1)
 
159
  try:
160
+ out_json=eval(json1)
161
  out1=str(out_json['filename'])
162
  out2=str(out_json['filecontent'])
163
  return out1,out2