Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Part 1
Lecture: CLI Concepts
0:01 Let's review the core concepts around using the command line to create a pyramid web application.
0:08 So it all starts with cookiecutter, and we can feed cookiecutter a whole variety of templates, there are a bunch for pyramid
0:17 and other application types as well; we're going to use pyramid cookiecutter starter,
0:22 this is the most straightforward, standard way to create a pyramid web application. There's a few others that bring in sqlalchemy in a certain way
0:30 or zodb or things like that, but this is really the best one for this course because we're going to focus on sqlalchemy later
0:37 and bring that in in a way that makes most sense for what we are doing. Ok, so we're going to use this cookiecutter starter
0:44 and all you need to know is what is the url to the github page. We're going to pip install cookiecutter
0:51 and maybe throw in a -U for upgrade and a --user so you don't modify the overall system, just modify for your user account.
1:00 So we're going to install this, and once it's all installed, we'll be able to run cookiecutter commands. So we're going to run cookiecutter
1:07 and we're going to give it that url from the git hub repository that contains the project template like this,
1:13 and once it runs, it's going to ask us a bunch of questions like what do you want to call the project,
1:19 this is like the friendly name you show to the user, what's the repo name, this is the actual Python package name
1:24 and make sure that you pick Chameleon for your template type here, okay. After that, we're going to have our project generated,
1:32 and it says you can do a couple of things which we will more or less do, we're going to change into the project directory,
1:38 we're going to create a virtual environment, remember I called it .env, not env, and I added a --copies flag for PyCharm plus mac interaction,
1:48 we also probably want to as soon as we get that activated, we want to install the newest tools,
1:54 I don't think that's shown actually here in the steps— no, it's not so we'll say .env/bin/activate, or .env/scripts/activate.bat on Windows,
2:09 and then we'll come down here and we'll upgrade our setup tools to the latest version;
2:13 remember setup tools itself is actually quite out of date for some reason, and then we're ready to run our app,
2:19 we just say pserve development.ini, and everything goes. Now before we can actually run our project,
2:26 we're going to need to register the website as a package in our virtual environment, so we'll say Python setup.py develop
2:36 and it's going to download all the dependencies as well as register our actual web application as a package basically.
2:42 And the develop we'll say look back here symbolically rather than linking over to copying those files over
2:51 that means we just continue to edit these files and Python just picks it up. So that's exactly what we want.
2:57 And then we're ready to run our app, so we just come down here, pserve development.ini and it should just run like this.
3:03 So here you can see running on local host on the particular port, it might seem weird that it's listed twice,
3:09 but that one is an ipv4 listing and another as an ipv6, even though it says local host in both, it's really one is ipv4 one is ipv6.
3:20 Take this url, open it up in your browser and boom you now have pyramid running in your browser, it's ready to go,
3:27 the only thing left— let's start adding features and making it your website.