Modern APIs with FastAPI and Python Transcripts
Chapter: Course conclusion and review
Lecture: Review: Rendering templates

Login or purchase this course to watch this video and the rest of the course contents.
0:00 FastAPI is an API first framework,
0:02 meaning if you just write basic view methods and return stuff,
0:06 it's going to treat it as JSON data and kind of talk to in styles that
0:11 typically API's and think consuming API's would expect.
0:14 But that doesn't mean you can't actually do basic Web stuff,
0:18 HTML stuff, there. So Flask supports Jinja templates, and that is also built into
0:24 FastAPI. So we could come over here and write our index.html,
0:28 which derives or extends from layout.html. In order to use it,
0:32 all we have to do is come over here,
0:34 create the templates object and say where the templates come from.
0:38 Remember, this means we have to pip install Jinja in order to do so. And
0:41 then during our function, we want to return HTML,
0:45 we just say templates, template response,
0:47 give it the name of the template and then some kind of dictionary
0:50 with all the values being passed over.
0:52 You have to have request in anything else you program against,
0:55 But request is a minimum. And that's it, now you have a web framework
0:59 on top of FastAPI.