From the course: Hands-On Introduction: Python

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Searching through data

Searching through data

- [Instructor] So at this point we have a web application that sort of returns all the laureates. It would be cool to add some search functionality to it. So let's go ahead and see how we can do that with what we've learned so far. So here I am in my code space at my exercise files in 04_03_begin, app.py. And here there is a laureate's list route similar to the laureate route that I had before. And what I did here is I instantiated an empty list of laureates. The first thing I do is I check if there is a ram for surname in the URL. And if there isn't, I return an empty list. But if we make it to this piece of code that means there is a surname peram. And what I'm going to do is I'm going to get this peram by saying search_string equals request.args.get. And I'll just say surname. And I'm going to tweak it a little bit. I'm going to say that it's lowercase to make sure that it's kind of a loose match. And I'm also…

Contents