RESTful and HTTP APIs in Pyramid Transcripts
Chapter: Your first service
Lecture: Project structure
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
So you saw a little bit of the project structure, but let's focus on the individual details, so you can see where to go to configure
0:09
or write code to affect a certain part of the app. So I used the tree command, which you can brew install onto MacOS,
0:16
to give me a hierarchical view here. So at the top, we have our project root I'm in the main directory
0:21
that was created, the one that has the setup.py and things like that; over here, you'll see that there are some package management files,
0:29
there's some read only details that get pulled in as well as the setup.py which is the most important thing that installs the dependencies,
0:37
that installs the website as a package itself, and so on. Next, we have our web application root, this is almost always
0:45
the exact same name as your root directory, your package root but is a subdirectory of that,
0:51
so here we have auto service api, there is really the root of our service
0:54
and in here we have the __init__ which represents the entry point to this package, and that is the entry point into your web application.
1:02
So this is where the start up and configuration code part of it goes, we've got our static client side cached files here,
1:09
we have our dynamic view folder, so our templates we're going to pass the models to the Chameleon, Jinja 2
1:17
or whatever type of templates and they're going to turn that into pure HTML and those are in the templates folder here,
1:22
we have a my template in a layout, the layout is like the overall look and feel for the site
1:26
and my template just brings in what's different about that page. So you should really look at how those fit together
1:33
if you are adding more pages along the same line. We have the code that is going to run our tests, there is some basically starter example code
1:40
on how to create a test version of your app, started up but not actually run the web server
1:46
and then make requests, fake requests, and things like that to it. So if you want to write tests, you definitely want to look there.
1:53
And you'll be spending a lot of time in the dynamic view folder, so here's where you write the functions that are your mapping routes
2:00
to that actually do the work; now it doesn't have to live in this views folder, like I strongly encourage you not to put
2:06
every single part of your website to the single file, that would be very wrong;
2:10
we'll see one of the first things we do is organize this into a different structure,
2:13
but by default this is the structure they use and that's where your views live. Finally, we have our configuration files here,
2:20
so we've got our development.ini and our production.ini the idea is you run the development one in development and the production one in production,
2:28
but it's really just the command line arguments you set up to run. So now you have a better understanding of all the working parts
2:34
of your website, it's time to start writing some actual service code.