Now, let's allow users to look up information for stocks
that they're interested in.
For quote, you have three tasks.
One is to display a form where the users can inquire after this information.
Second, you want to retrieve that information,
the stock quote, and then display it back to the user.
So let's start by displaying a form to the user where they can look up
information about these stocks.
For this, let's create a new template, quote.html.
We'll want to write a form for the stock look up,
where the form input is the symbol for the stock
that the user wants to look up.
Now that that user has given us a symbol, let's take that symbol
and retrieve the relevant information.
The lookup function uses an API to retrieve information
about a stock given a symbol.
It will return a dict, the name of that stock,
the current price, and the symbol of that given stock.
Now that we have this information let's relay it to the user.
We'll want to display this stock information in another template.
Why are we creating a new template?
Well, it's because the quote.html template already has a form.
This is going to look different, so we'll create a new template.
Now, we only want to display this new template,
if the stock symbol that the user provided is valid.
Otherwise, we'll apologize again.
Now, this stock information is in Python,
but we're displaying information in HTML.
So how do we communicate between these two files?
Well, let's take a look at render_template.
Render_template allows us to pass in values from Python to HTML.
Let's say I have a template called hello.html.
Let's go to the main block.
Here, you'll see that I have HTML paragraph tags.
Within it, I say, Hello comma.
And, then, I have a placeholder for a Python variable
enclosed into curly braces.
So, then, within application.py when I'm defining my route for hello,
I'm going to call render_template, passing in the name for the template
that I'm rendering, as well as, the value for the variable name.
So what would the HTML look like?
If I passed in world, then I'd be able to say, hello, world!