Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Part 1
Lecture: CLI Introduction

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