RESTful and HTTP APIs in Pyramid Transcripts
Chapter: Your first service
Lecture: Concept: Creating the site

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's look at the steps that we had to take to create and run our web application. Remember, the first thing we had to do was make sure
0:10 that we actually had cookiecutter itself installed because pyramid is now switched to a cookiecutter template model
0:16 for all of their projects, so we need to run cookiecutter against their template, that means we've got to have cookiecutter.
0:21 So we did a pip 3 the install--user cookiecutter you may have to set the path depending on how is system setup,
0:26 it may just run, I've seen it sort of work both ways; so we install cookiecutter, once we have cookiecutter working
0:33 you can pick a template, for the purpose here I think the Pyramid cookicutter starter is totally fine.
0:41 There is one that you can pick that has sqlalchemy set up but you'll probably want a lot of control over that anyway.
0:47 So we'll do that in the later section, and it will set up sqlalchemy, the data access layer, but here we get pretty simple one page basic website,
0:55 so cookiecutter space the url to the github repository, not the . git part, although I believe that would also work
1:02 but actually just the url to the github repo page. Cookiecutter asks you a couple of questions before it actually creates the website
1:09 so here we gave it the name auto service api and auto_service_api for the lower case name and then we chose Chameleon, and it ran correctly
1:19 and gave us a few steps on hey here's what you might do next. So you see the next thing it says it's to go into that directory
1:26 and create a virtual environment, we do almost that we do create the virtual environment, we give it a slightly different command.
1:33 So then we go into where the web app was created to its primary directory, we create a virtual environment
1:39 and we use the . env rather than straight env, that makes it both hidden but also PyCharm automatically detects and uses that,
1:47 which is very handy, and we give it the --copies at least on MacOS, because the resolution of the symlinks doesn't quite work right in PyCharm,
1:58 and possibly other environments as well, this is the one reverend to issues and copies fixes that, so we've now created our virtual environment,
2:05 but it's still not active, if we do pip or Python is running the system one, notice of the prompt is unchanged, so the next thing to do
2:11 is to activate the virtual environment, so we say source or . env /bin/activate like I said,
2:18 on Windows it's scripts and activate that, source not required and our prompt should change. Then if you ask things like which or where Python,
2:25 it will pull up the actual path to the one that's in that virtual directory, so you know it's working.
2:31 After that, we need to install Pyramid, all the dependencies of our web app
2:35 which depending on how the scaffold runs is often beyond just Pyramid itself, things like pyramid debug toolbar and waitress and so on;
2:43 so to accomplish that as well as register the package itself, remember, pyramid projects are Python packages
2:49 we run Python against the setup.py and we give it a developed argument
2:53 and that's going to tell it to install all the dependencies, and install it locally. After this, we're ready to run, so we just use the p.serve command
3:01 which comes along as part of that setup process when we install pyramid it comes with p.serve, and t hen we can p.serve development.ini
3:09 that starts up our web app and we're off to the races. We have a wonderful new website that we're ready to start adding a web services to.


Talk Python's Mastodon Michael Kennedy's Mastodon