© 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_5

5. Response

Malhar Lathkar1  
(1)
Nanded, Maharashtra, India
 

Any web application returns an HTTP response to the client. The operation function in a FastAPI app returns a JSON response by default. In this chapter, we shall learn how we can manipulate the response to handle different requirements.

In this chapter, the following points will be discussed:
  • Response model

  • Cookies

  • Headers

  • Response status code

  • Response types

The FastAPI operation function JSONifies Python’s primary types, that is, numbers, string, list, dict, etc., as its response. It can also return an object of ...

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.