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