So let's get started building the page, and the first page I want to build is to sell a single product,
in other words, a one time purchase and in the course resources.
For this lecture, you'll find an image called Widget PMG.
And you can see that I've already downloaded that, already copied it into a folder called Static at
the root level of my project.
And that's where I'm going to put the images for anything I want to sell.
So, of course, that means that we need to open our rootstock go file, which I have already done,
and we need to be able to serve static content.
Now, we could embed this into our project the same way that we embedded our templates, but I find
that a little awkward.
And right now I'm just going to serve them from an external directory.
So the first thing I'll do is after my existing routes, I'll create a variable called file server and
I'll use the assignment operator and I'll simply create that using http dot file server right there.
And the directory I want to serve is these are not static.
OK, so that creates the variable and I will handle any request to slash static so much start handbell
and I want to look for the path.
Static slash so slash static slash star and we'll use htp dot prefix as is the norm.
We're going to strip off slash static and hand it file server.
So once that re compiles and it's re compiled, I should be able to hit that image by going to my web
browser and typing in localhost port for thousands of static widget dumping.
Now let's create our necessary template.
So inside the templates folder, I'll create a new file and I will call that file just by dash once
dot page dot go html.
And it's a very simple file.
First of all, it'll use the template base and we'll handle the data and we'll define the title.
So the title block and all overwrite the default content by putting in by one widget.
And no, I'm not sure what a widget is and it doesn't matter.
Then we'll end that and then we'll have our content block to find content
and I'll put my end in now so I don't forget.
And and we'll do pretty much the same thing we did before.
So for right now, let's just get it the page up and running.
I'll put it in H2 and I'll give it a class of try that again.
Class of, say, emergen top three and text center and I'll use the title by one and I'll capitalize
that one widget and close my eyes to kind of put a horizontal rule in and then I'll put in the image.
So image source equals static slash widget PMG and we'll give it all text of just widget and the class
will just use our boot straps class, say image dash fluid, rounded emacs dash auto and dash block.
OK, so let's create a handler that serves this route up, so we'll go to our handlers right here,
handlers dog go and I'll hide my terminal.
And at the very bottom of this file, I'll put a new function in there.
And it's a very simple handler.
So func, I'll call it up.
The receiver is an application and I'll call it charge once and it's a handler.
So WHV don't response writer and a pointer to a request
and all will do for now is serve that template.
So we'll say if error is assigned the value of our render template and we'll hand it response or the
request and we'll call this charge Dasch once, which is what I call that template.
I called it by once.
Try that again, VIDAZA once and I'll give it a Nhill for the data for now and then check for an error.
Error is not equal to nil.
Then we'll just say after error log print line error and I'll give it its comment.
Charge once displays the page to buy one widget and let's go back to our roots and set up a route to
that.
So I'll put it right before my static declaration marks get and I'll just call this charge dush once
and it handle.
It's handled by Abda to charge once.
OK, so if everything went according to plan they should rebuild.
Good.
And I should be able to go back to my web browser and just change the URL from virtual terminal to charge
Dasch once there is.
So we have one one title and we have our widget image and now we need to put together a form and create
the necessary logic to bind this one widget.
So we'll get started on that in the next lecture.