I have a method to read the .json I have in a folder inside the api in flask The method in question I pass a directiorio (dir) and I go through it with a for as it is a folder more folders inside and within these latest folders the .json
-estaticos
-modelo1
-modelo1.json
-modelo2
-modelo2.json
and I read it in the following way
for root, dirs, files in os.walk(dir):
for name in files:
if nombre:
if nombre == name:
My question is, how can I do to return the entire .json file once I find it? (inside the if) without having to read it line by line since this creates some separators that I would not like to have.