I'm trying to create a Rest JSON server using python and flask as backend and JavaScript as front end, the server data need to be saved in local file but i can't seem to find a way to store the data like :
[
{'id': id, 'name': name},
<--- New record from POST request goes here
]
what i mange to do is:
def create(name, title):
record= str({'id': id, 'name': name}) + '\n'
rlist= open('static/notes-list.txt', 'a')
rlist.write(note)
rlist.close()
# Then for getting data
def get_data():
f= open('static/notes-list.txt')
content = f.read()
f.close()
data= content.strip().split('\n')
return data
but this give me array of stings in fetch data`['{...}','{...}']