Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building Data Science Applications with FastAPI

You're reading from  Building Data Science Applications with FastAPI

Product type Book
Published in Oct 2021
Publisher Packt
ISBN-13 9781801079211
Pages 426 pages
Edition 1st Edition
Languages
Author (1):
François Voron François Voron
Profile icon François Voron

Table of Contents (19) Chapters

Preface Section 1: Introduction to Python and FastAPI
Chapter 1: Python Development Environment Setup Chapter 2: Python Programming Specificities Chapter 3: Developing a RESTful API with FastAPI Chapter 4: Managing Pydantic Data Models in FastAPI Chapter 5: Dependency Injections in FastAPI Section 2: Build and Deploy a Complete Web Backend with FastAPI
Chapter 6: Databases and Asynchronous ORMs Chapter 7: Managing Authentication and Security in FastAPI Chapter 8: Defining WebSockets for Two-Way Interactive Communication in FastAPI Chapter 9: Testing an API Asynchronously with pytest and HTTPX Chapter 10: Deploying a FastAPI Project Section 3: Build a Data Science API with Python and FastAPI
Chapter 11: Introduction to NumPy and pandas Chapter 12: Training Machine Learning Models with scikit-learn Chapter 13: Creating an Efficient Prediction API Endpoint with FastAPI Chapter 14: Implement a Real-Time Face Detection System Using WebSockets with FastAPI and OpenCV Other Books You May Enjoy

Structuring a bigger project with multiple routers

When building a real-world web application, you're likely to have lot of code and logic: data models, API endpoints, and services. Of course, all of those can't live in a single file; we have to structure the project so that it's easy to maintain and evolve.

FastAPI supports the concept of routers. They are "sub-parts" of your API and are usually dedicated to a single type of object, such as users or posts, that are defined in their own file. You can then include them in your main FastAPI app so that it can route it accordingly.

In this section, we'll explore how to use routers and how you can structure a FastAPI project. While this structure is one way to do it, and works quite well, it's not a golden rule and can be adapted to your own needs.

In the code examples repository, there is a folder named chapter3_project, which contains a sample project with this structure: https://github.com...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}