Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Part 1
Lecture: CLI Introduction
0:01 Are you ready to start writing some code for the web in Python? Yeah, I definitely am, it's time to get started.
0:09 So that's what we are going to do in this section. So what are the steps to create a project and get started in pyramid?
0:16 The first thing that we're going to do actually is not to install pyramid but to install a template manager program
0:23 that will then install everything or create everything that we need for our pyramid web applications.
0:29 So we're going to use this thing called cookiecutter. Now cookiecutter manages all sorts of project templates
0:36 and it has hundreds, maybe even thousands of them available. Many of these are for pyramid, and so we're going to install cookiecutter,
0:44 external separate package, and then we're going to use cookiecutter to use template or a scaffold to create the starter website.
0:54 Now, pyramid web applications have a lot of moving parts, almost all web applications that are realistic have a lot of moving parts,
1:10 so you might see examples where somebody uses flask or something just create a here is the one function you write to create your app,
1:18 you can do the same thing in pyramid, but it's not realistic, it doesn't really set up what you need,
1:23 so this cookiecutter process will put all those pieces together just like you need for pyramid to get going.
1:29 Now, one of the things I like to do especially for web applications is create a virtual environment. Virtual environments in Python allow us to set up
1:39 a separate copy of the dependencies and a separate set of the dependencies for individual applications, so this means that if I have three web apps,
1:47 maybe one is using a newer version of pyramid or a new version of sqlalchemy, and the other one is using an older one
1:53 because we haven't upgraded it yet. And this means that we can run both of those, side by side on our machine,
2:00 we don't have to change our global environment and possibly even mess up our system. So we're going to create a virtual environment,
2:07 this is technically optional but highly recommended; pyramid web applications are a little bit different in that
2:13 in their full form they are actually Python packages, so that means we need one additional step, one additional command that we enter
2:21 to register this in our virtual environment system or whatever Python system we're running in.
2:27 So we'll run that and then, we'll serve our web application we'll add some features, and then we'll just go round and around
2:34 and iteratively develop our app, until it's ready for deployment. How do we go through these steps?
2:41 We can choose one of two options— if you have PyCharm professional PyCharm will let you click a couple of buttons, go through one or two screens,
2:50 and it will take you through all of these steps. But even if you're going to use PyCharm, which you don't have to,
2:55 but if you are going to, it's still nice to see the command line version so you know what the actual steps are, you know the way things fit together.
3:04 When you get to PyCharm, you can click the few buttons and be really happy that it put all the pieces together,
3:09 but really understanding how your web app works is important. If you have PyCharm community edition,
3:16 or you're using something else, like Sublime Text or Visual Studio Code or Emacs
3:20 or some other editor that doesn't have this project template mechanism, you're going to go through the command line edition.
3:26 And then of course, you just open it up in that editor. So for this one, we're going to choose the cli.
3:32 Let's jump over to our Mac and create our first project.