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


Talk Python's Mastodon Michael Kennedy's Mastodon