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