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,
0:05 so you can see where to go to configure
0:08 or write code to affect a certain part of the app.
0:11 So I used the tree command, which you can brew install onto MacOS,
0:15 to give me a hierarchical view here.
0:17 So at the top, we have our project root I'm in the main directory
0:20 that was created, the one that has the and things like that;
0:25 over here, you'll see that there are some package management files,
0:28 there's some read only details that get pulled in
0:31 as well as the which is the most important thing
0:34 that installs the dependencies,
0:36 that installs the website as a package itself, and so on.
0:40 Next, we have our web application root, this is almost always
0:44 the exact same name as your root directory,
0:46 your package root but is a subdirectory of that,
0:50 so here we have auto service api, there is really the root of our service
0:53 and in here we have the __init__ which represents the entry point to this package,
0:58 and that is the entry point into your web application.
1:01 So this is where the start up and configuration code part of it goes,
1:04 we've got our static client side cached files here,
1:08 we have our dynamic view folder, so our templates
1:12 we're going to pass the models to the Chameleon, Jinja 2
1:16 or whatever type of templates and they're going to turn that into pure html
1:19 and those are in the templates folder here,
1:21 we have a my template in a layout,
1:23 the layout is like the overall look and feel for the site
1:25 and my template just brings in what's different about that page.
1:29 So you should really look at how those fit together
1:32 if you are adding more pages along the same line.
1:34 We have the code that is going to run our tests,
1:36 there is some basically starter example code
1:39 on how to create a test version of your app,
1:42 started up but not actually run the web server
1:45 and then make requests, fake requests, and things like that to it.
1:49 So if you want to write tests, you definitely want to look there.
1:52 And you'll be spending a lot of time in the dynamic view folder,
1:54 so here's where you write the functions that are your mapping routes
1:59 to that actually do the work; now it doesn't have to live in this views folder,
2:02 like I strongly encourage you not to put
2:05 every single part of your website to the single file, that would be very wrong;
2:09 we'll see one of the first things we do is organize this into a different structure,
2:12 but by default this is the structure they use and that's where your views live.
2:16 Finally, we have our configuration files here,
2:19 so we've got our development.ini and our production.ini the idea is
2:23 you run the development one in development and the production one in production,
2:27 but it's really just the command line arguments you set up to run.
2:30 So now you have a better understanding of all the working parts
2:33 of your website, it's time to start writing some actual service code.