HTMX + Flask: Modern Python Web Apps, Hold the JavaScript Transcripts
Chapter: Surveying the non-js-enabled Flask app
Lecture: Concept: Code organization

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We saw the pieces of code that we're working with.
0:02 We saw the models and the views, and we even saw some few models stuff.
0:06 But I want to highlight a little bit more organization than we've seen so far. So over
0:11 in our project structure. We have a couple of things.
0:15 We have our View models and notice the View models have a home folder.
0:20 And in there we have the index_viewmodel.
0:23 So here in the views we have a home file and an index method.
0:28 Both the folder structure and the view models as well as the name of the file
0:32 have a direct correlation. So if you're in that index_viewmodel and the home
0:36 folder, well what does it apply to? the home set of views and the index
0:41 method. Also, it derives from the ViewModelBase in shared.
0:47 Everyone's going to be sharing that.
0:48 No one really directly uses that.
0:50 Just like the view models have a sub structure that matches the view and method name
0:55 So do our templates. So we have our template folder which again has a
0:59 home folder because that has to do with the home views and the
1:03 there. And we have a method called index.
1:05 So we have an HTML file called index.html.
1:10 So this helps us know if we're in one section.
1:12 If we're working in HTML. What is its view model?
1:14 What is its actual view implementation?
1:17 You can use these two steps.
1:19 What is the name of the view file or collection? home and what is the name
1:24 of the method? index. And that will help you quickly know where the various
1:28 pieces go. So this is how I've organized everything.