Effective PyCharm Transcripts
Chapter: Server-side Python web apps
Lecture: Concept: PyCharm server-side features

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's just take a couple minutes and review some of the server side concepts that we've
0:05 seen for PyCharm and actually touch on a few more that we didn't really call that specifically in our demo we started by saying,
0:11 let's create a new project, We'll click that new project button up in the top We could create Django, Flask,
0:17 Google app engine, Pyramid or Web2Py pick on any one of these and you get to select the particular details. So for example, if we pick Django,
0:26 we can decide whether or not to enable the Django admin. so, really quick and easy way to create these PyCharm has fantastic HTML support
0:34 because it's built on WebStorm but it also has rich server side template support.
0:40 So here for example, we're working in a HTML template that is a Chameleon template
0:45 It's wrapping a larger common look and feel shared underscore layout dot pt file. We want to add a div that has some template attribute language,
0:54 some tal code on it. Right. This is the way things work in chameleon so we say tal colon and boom,
1:00 look at that. We get all the language features of chameleon. Super, Super cool. If you're going to create structured HTML that has especially repeated
1:09 items, you can use zen coding. You just write basically CSS expression of what you wished existed.
1:16 For example, here's a div that has a class menu contains a 'ul'. That has an id.
1:21 menu list and within there there's five list items that are the class menu item
1:28 who hit tab and boom it auto expands that and we even guides us through filling out the elements of our list items.
1:35 Super, super, cool. So if you're going to create something that has the structure, you really know precisely where you're gonna get,
1:42 take a moment before you just start writing it all out and remember that you can do this. Cool little zen,
1:46 Coding expansion if you need to change a tag, especially on large files, it can be really air prone up on one section.
1:54 You want to change say a div to a span, you gotta go down to the bottom and remember this was the closing div tag that
2:02 matched the one that I changed and if you get it wrong, boom things are gonna crash. Not just your HTML will look bad but these server
2:09 side templates will crash, they can't pars themselves and it's all sorts of badness. The PyCharm has a cool trick.
2:16 You just type on the definition to change the tag name and guess what? It will change the corresponding closing one as well.
2:23 So here if we go to the select 'div'. For the opening div type span and see the bottom slash div has changed our correspondent
2:30 We updated to slash span. We also saw in great CSS support so if we bring in some CSS library or
2:40 if we write our own and we go work with a class on the HTML side It will auto complete all of the classes and id's and stuff that we've worked
2:49 with before and vice versa. If we define, we start using some class names or 'id'. names in HTML and then go work on the CSS side.
2:59 It auto completes those as well and it looks like you're trying to use this tweet class that you define over in your template.
3:06 So bi directionally we get awesome support for CSS Auto complete here's when we haven't touched on, although you may have noticed,
3:14 check out this thing at the bottom. So here we are in a template, it's gonna div that has a class content.
3:20 It's kind div inside there, that's a hero then a row and then a smaller column thing and then a sub hero. So if we put our cursor online,
3:28 15 check out was here on the bottom. It shows us the hierarchy, it shows us that we're in the div to install
3:36 dot sub hero which is contained in the small column of block size eight, which is in a row which is a hero and you can actually click on those
3:45 especially helpful in a very large file. Like what is this hero thing. Again, you could click on 'div.hero' would jump you to line six and
3:53 then you can click back onto the red piece that would take you back to where
3:57 you are. So it will do that without actually moving your cursor and losing track but it lets you quickly explore the hierarchy of HTML.
4:03 So don't forget about this. It's incredibly helpful on large and complicated HTML pages. We saw a static file support is fantastic,
4:12 but only if we set it up correctly. So it got set up correctly in our flask app because we created it from scratch
4:19 in PyCharm. But if that wasn't the case, you might need to indicate the PyCharm right here. This subdirectory actually corresponds to '/static'.
4:28 So the way you do that is you go to the directory at the top in this case chapter eight 'Async', databases and we mark that as a resource root.
4:37 Not static but the thing that contains static. When we do that, you can see the errors of the missing CSS pieces are gone and we get auto complete.
4:47 Super cool. We could even go to definition with 'cmd+b' or command click or
4:52 you know the control version on the other OS. Finally I did mention there's ways to run little tasks like bundling and minification and whatnot.
5:01 So if you go to the run configuration for your web app and then scroll down often this is off the screen, there's a little before launch, hit the plus,
5:09 check out what you get file watchers, grunt task, Gulp task, npm task compiling,
5:15 Typescript. running something else, some other Python code that you write launching a web browser, all sorts of stuff.
5:22 So pretty much endless ways to prepare your web app to run before it actually opens
5:29 and starts running the Python code here and that's it for our service side features that
5:33 we're going to cover. This is one powerful web application for building Python web apps that involve all the various pieces that modern web apps do.
5:42 I absolutely encourage you to check it out. This is the tool that we use to build,
5:46 Talk Python Training and all the API's powering it from the back end and it is a joy to you. So hopefully you can get as much out of it as we do.


Talk Python's Mastodon Michael Kennedy's Mastodon