save
that saves the visitor’s data to a JSON file. The file name should be named like this visitor_{some_number}.json
. The number part of the file name should be automatically generated as you save the visitor. eg:alice.save() # results in visitor_1.json
bob.save() # results in visitor_2.json
charlie.save() # results in visitor_3.json
load
that takes in a number and returns a Visitor object that was saved to file.eg:
alice = load(1)
bob = load(2)
alice = Visitor(...stuff)
alice.save() # creates a file
alice.age = 93
alice.save() # DOES NOT create a file. This updates the original file
This should also work:
bob = load(2)
bob.comments = "great personality"
bob.save() # should update visitor_2.json
Use Flask to expose the following functionality:
Imagine that your api is hosted somewhere on the internet and is very popular. Lots of people are using it.
A lot of really weird bugs can creep in. This class of error is generally referred to as a race condition. There are tools and techniques that exist to help deal with this kind of thing. In general it’s good to keep race conditions in mind whenever dealing with processes that access data in parallel.