© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
M. LathkarHigh-Performance Web Apps with FastAPIhttps://doi.org/10.1007/978-1-4842-9178-8_4

4. Templates

Malhar Lathkar1  
(1)
Nanded, Maharashtra, India
 

FastAPI, as its name suggests, is primarily intended to be a library for API development. However, it can very well be used to build web apps of traditional type, that is, the ones rendering web pages, images, and other assets.

In this chapter, we shall learn how FastAPI renders web pages with the help of templates.

This chapter consists of the following topics:
  • HTML response

  • Template engine

  • Hello World template

  • Template with path parameter

  • Template variables

  • Serving static assets

  • HTML form template

  • Retrieve form data ...

Get High-Performance Web Apps with FastAPI: The Asynchronous Web Framework Based on Modern Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.