Python for .NET Developers Transcripts
Chapter: Course conclusion
Lecture: Web apps review
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
The next topic we covered was building web applications with Python and we saw that Python was an amazing platform
0:07
for the web and tons of cool apps are built with it. We decided to choose Flask because it's familiar. I've somewhat liked the ASP.NET MVC
0:16
and it's also really popular. So, in order to do that, create a Flask web app we're going to import Flask
0:22
and create a Flask instance, based on the name of the file. We're going to have some main method, which runs it could say, debugger is false
0:30
debugger is true, take your pick. We saw also in production that that main method doesn't get run so you can really kind of just do you dev stuff there
0:38
then if we want to have, method a URL route we're going to say, we're going to define a method that is guitar list. The name doesn't really matter
0:45
but it's going to matter to us I guess, right? This is where we list our guitars so we're going to add an app.route
0:51
we're going to say /guitars/variable named style. And then notice how style is passed in guitar list and then we just do our own implementation
1:00
we go to the guitar service we say give us all the guitars by that style and then we render a template guitars.html which is a Jinja2 template
1:08
which is a dynamic way to write HTML and then put a little bit of Python logic in there to turn our Python data, into HTML.
1:16
That's it, besides the HTML template really the whole app right there