Using and Mastering Cookiecutter Transcripts
Chapter: Getting started using Cookiecutter
Lecture: Demo: Creating a project

Login or purchase this course to watch this video and the rest of the course contents.
0:02 You've seen there is some really cool projects, or templates
0:06 that we can grab from that pantry and go and create things.
0:09 Let's look in a particular one,
0:11 here we've got one that will create a Bottle web application.
0:14 So Bottle is what you might call a microframework,
0:17 in the Python web framework space, so we can use this template
0:21 to create one along with the dependencies, and a little bit of starter code for us.
0:24 Let's start over here in the pantry, and you can see right here,
0:27 I've already clicked on it, cookiecutter-bottle
0:30 for creating reusable Bottle projects quickly.
0:33 Alright, so we can go over here and notice, this is just a public git repo,
0:36 and the way you can there is some Cookiecutter stuff going on
0:39 is this {{cookiecutter.stuff}} we'll see what that means later,
0:44 but if you look inside here, basically these are the files
0:47 that are going to be used when you run the template.
0:50 Like I said, when we get to another section about creating our own templates,
0:53 we'll go way into detail there, but notice, I can just take the url,
0:56 not the clone url or the get url, just the url to the repo itself.
0:59 And I can come over here and I can install that using Cookiecutter,
1:04 so I am in our shared source so whatever I do here you will be able
1:09 to get so I am going to start by saying Cookiecutter that,
1:13 I am just going to give it the https url to the git repo here.
1:18 Now I could also give it a path to a directory if I had
1:20 for some reason downloaded and cloned this, but I don't need to,
1:23 Cookiecutter will do that for us, okay, so we run it,
1:27 it takes just a moment to quietly clone it in the background,
1:30 it asks us what our name is, I'll go and put my name,
1:33 it asks us what our email is, I'll do that as well,
1:37 my GitHub, no that's not me, that is me,
1:41 and what I want to call this, Super bottle web, something like that,
1:45 and I'll just call it super_bottle, like that, this needs to be
1:48 some kind of folder that Python could use as a web app name,
1:53 so probably no spaces, things like that and you will see later
1:57 that you can actually validate it, I don't know if this template does,
2:00 we hit enter and if I don't want to put a description
2:03 and I am willing to take whatever they put in here, if I just hit enter,
2:06 any of these things in the brackets for example mybottleapp
2:09 or that version of it or this, if I just hit enter that is going to be
2:11 the description that is used, so everything in a bracket is just a default,
2:15 we'll see how you can set up global defaults for yourself as well later
2:18 but the template is giving you a default first,
2:21 right, we hit enter and done.
2:24 So, let's see what we got, well,
2:26 we've got a super_bottle folder here, let's open it up and have a look.
2:29 So if we go in here, notice we've got the manage.py we've got the README,
2:33 let's go over here and cd into the super_bottle,
2:36 and just look at the README here, so here you can say
2:42 it's a cookiecutter template for creating this
2:45 and this is the default that we saw right here,
2:48 see my Super bottle web, and so on, it shows me how to get started,
2:50 so python manage.py runserver
2:53 Okay, that's cool, now actually I am going to need to install these requirements here
2:59 I don't have Bottle or Click or Jinja2, potentially installed,
3:03 now you don't need to know any Python to use Cookiecutter,
3:05 but just to show you I can take this thing and run it for that,
3:08 because it's a Python web app, we got to do a really quick thing,
3:10 so let me just briefly create a virtual environment
3:13 so this thing doesn't actually affect my machine here,
3:16 so what I am going to do is I am going to say python3 -m venv [path]
3:20 and this can be a clean place
3:22 where we just install things for the rest of this class here,
3:25 so that was cool, that worked, and then I got to activate it,
3:28 okay, notice that my prompt has changed, okay, great,
3:32 so let's go ahead and install the requirements,
3:36 we'll say pip install -r requirements
3:39 so it's going to download all the packages that this thing
3:43 that was just created needs to run, and now, we can just say
3:46 python manage.py runserver and look at that, it's up and running,
3:50 let's go see what we got here.
3:53 Congratulations, our app worked,
3:55 okay, great, so now go write your web app, basically,
3:57 but it's setup that structure, the requirements,
3:59 all that so we could get started more quickly.
4:03 This is pretty cool, right, well, there is not a lot going on here,
4:05 because hey, this is Bottle, it's a micro framework,
4:08 if we had done this with Pyramid, you would have seen actually
4:11 a lot more stuff happen and we'll do that later.