#100DaysOfWeb in Python Transcripts
Chapter: Days 37-40: Introduction to Pyramid framework
Lecture: Creating the app: Intro
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let's talk about how you get started with a Pyramid project, creating a new one from scratch. Now this is a little bit more involved than Flask
0:08
because Flask just says create a Python file but it gives you no help. You'll see that the way we start here is going to push us
0:13
way farther down the line in terms of structure. We'll have static folder and places for our CSS places for our templates and so on.
0:22
So we're going to get started by using this package called Cookiecutter. It'll let you install and create arbitrary templates for new projects.
0:30
Some of these are Python, like there's some for Flask and Django and of course Pyramid but there's also stuff for even weird things like Atari.
0:36
It just generates a bunch of files in a well-known structure by asking you a couple of questions. We're going to use Cookiecutter
0:42
to start way farther down the path with the right structure for our project. Then once we have Cookiecutter installed
0:48
and set up in our path, if it's not we're going to use Cookiecutter to create the starter site.
0:54
There's about four or five different Cookiecutter templates that we can use, and I'll talk about those.
0:57
We can use any of them to create our starter site depending on what we want to start from. Then we're going to create a virtual environment
1:06
around this project. This is good advice for any of the web frameworks. They all have dependencies and things like that
1:12
and you're way better off having a single dedicated Python environment for that web application so we'll do that.
1:18
Pyramid is a little special in that it wants you to treat the website as a Python package. You don't have to know much about Python packaging
1:26
but you do have to run a separate command basically to tell the Python runtime. CPython, hey when you're looking to run this website
1:33
it lives right here. So we're going to run a certain command to do that. And then it's time to just start working on our site.
1:40
The first four steps, we do that to get started then we serve it up figure out what features we want to add, test them
1:46
and then serve it up again, see if that worked add more features, and we just keep evolving it. So this is the general workflow
1:52
of working with Pyramid from the command line from a tool that doesn't have native Pyramid support. If you're talking about PyCharm
2:00
well, that's like click a button and answer a question or two and you're off to the races. But I want to make sure we go through
2:06
the command line version first so that you see everything that's happening just in case something goes wrong
2:11
you will know kind of of what you need to do. And then of course if you just prefer to click the button in PyCharm, go for it.