Sooner or later, you’ll need to safely store your data somewhere.
And when it comes to storing data, Python has you covered. In this chapter, you’ll learn about storing and retrieving data from text files, which—as storage mechanisms go—may feel a bit simplistic, but is nevertheless used in many problem areas. As well as storing and retrieving your data from files, you’ll also learn some tricks of the trade when it comes to manipulating data. We’re saving the “serious stuff” (storing data in a database) until the next chapter, but there’s plenty to keep us busy for now when working with files.
At the moment, your webapp (developed in Chapter 5) accepts input from any web browser (in the form of a
phrase and some
letters), performs a
search4letters call, and then returns any results to the waiting web browser. Once done, your webapp discards any data it has.
There are a bunch of questions that we could ask of the data our webapp uses. For instance: How many requests have been responded to? What’s the most common list of letters? Which IP addresses are the requests coming from? Which browser is being used the most? and so on, and so forth.
In order to begin answering these (and other) questions, ...