FastAPI is a young yet solid framework that takes advantage of newer Python features in a clean design. As its name implies, FastAPI is indeed fast, rivaling similar frameworks in languages such as Golang. With this practical book, developers familiar with Python will learn how FastAPI lets you accomplish more in less time with less code.


Author Bill Lubanovic covers the nuts and bolts of FastAPI development with how-to guides on various topics such as forms, database access, graphics, maps, and more that will take you beyond the basics. This book also includes how-to guides that will get you up to speed on RESTful APIs, data validation, authorization, and performance. With its similarities to frameworks like Flask and Django, you'll find it easy to get started with FastAPI.


Through the course of this book, you will:

  • Learn how to build web applications with FastAPI
  • Understand the differences between FastAPI, Starlette, and pydantic
  • Learn two features that set FastAPI apart: asynchronous functions and data type checking and validation
  • Examine new features of Python 3.8+, especially type annotations
  • Understand the differences between sync and async Python
  • Learn how to connect with external APIs and services


Table of Contents

Part I. What's New?

Chapter 1. The Modern Web

Chapter 2. Modern Python


Part II. A FastAPI Tour

Chapter 3. FastAPI Tour

Chapter 4. Async, Concurrency, and Starlette Tour

Chapter 5. Pydantic, Type Hints, and Models Tour

Chapter 6. Dependencies

Chapter 7. Framework Comparisons


Part Ill. Making a Website

Chapter 8. Web Layer

Chapter 9. Service Layer

Chapter 10. Data layer

Chapter 11 . Authentication and Authorization

Chapter 12. Testing

Chapter 13. Production


Part IV. A Gallery

Chapter 14. Databases, Data Science, and a little Al

Chapter 15. Files

Chapter 16. Forms and Templates

Chapter 17. Data Discovery and Visualization

Chapter 18. Games


This is a pragmatic introduction to FastAPI—a modern Python web framework. It’s also a story of how, now and then, the bright and shiny objects that we stumble across can turn out to be very useful. A silver bullet is nice to have when you encounter a werewolf. (And you will encounter werewolves later in this book.)


I started programming scientific applications in the mid-1970s. And after I first met Unix and C on a PDP-11 in 1977, I had a feeling that this Unix thing might catch on.

In the ’80s and early ’90s, the internet was still noncommercial, but already a good source for free software and technical info. And when a web browser called Mosaic was distributed on the baby open internet in 1993, I had a feeling that this web thing might catch on.


When I started my own web development company a few years later, my tools were the usual suspects at the time: PHP, HTML, and Perl. On a contract job a few years later, I finally experimented with Python and was surprised at how quickly I was able to access, manipulate, and display data. In my spare time over two weeks, I was able to replicate most of a C application that had taken four developers a year to write. Now I had a feeling that this Python thing might catch on.

After that, most of my work involved Python and its web frameworks, mostly Flask and Django. I particularly liked the simplicity of Flask and preferred it for many jobs. But just a few years ago, I spied something glinting in the underbrush: a new Python web framework called FastAPI, written by Sebastián Ramírez.


As I read his (excellent) documentation, I was impressed by the design and thought that had gone into it. In particular, his history page showed how much care he had taken evaluating alternatives. This was not an ego project or a fun experiment, but a serious framework for real-world development. Now I had a feeling that this FastAPI thing might catch on.

I wrote a biomedical API site with FastAPI, and it went so well that a team of us rewrote our old core API with FastAPI in the next year. This is still in production and has held up well. Our group learned the basics that you’ll read in this book, and all felt that we were writing better code, faster, with fewer bugs. And by the way, some of us had not written in Python before, and only I had used FastAPI.

So when I had an opportunity to suggest a follow-up to my Introducing Python book to O’Reilly, FastAPI was at the top of my list. In my opinion, FastAPI will have at least the impact that Flask and Django have had, and maybe more.


As I’ve mentioned, the FastAPI website itself provides world-class documentation, including many details on the usual web topics: databases, authentication, deployment, and so on. So why write a book?

This book isn’t meant to be exhaustive because, well, that’s exhausting. It is meant to be useful—to help you quickly pick up the main ideas of FastAPI and apply them. I will point out various techniques that required some sleuthing and offer advice on day-to-day best practices.


I start each chapter with a Preview of what’s coming. Next, I try not to forget what I just promised, offering details and random asides. Finally, there’s a brief digestible Review.

As the saying goes, “These are the opinions on which my facts are based.” Your experience will be unique, but I hope that you will find enough of value here to become a more productive web developer.


About the Author

Bill has been a developer for over forty years, specializing in Linux, the web, and Python. He coauthored the O'Reilly book Linux System Administration, and wrote both editions of Introducing Python. He discovered FastAPI a few years ago, and with his team used it to rewrite a large biomedical research API. The experience was so positive that they've adopted it for all new projects.

ISBN

9781098135508

برند

O'Reilly

تعداد صفحات

280

سال

2024

course image

ایزی اگزم

90%رضایت مشتریان عملکرد عالی

نام مولف:

John Priece

نام ناشر:

O'Reilly

موجود نیست

متأسفانه این محصول در حال حاضر موجود نمی باشد