Gen-AI Developer Classroom notes 26/Oct/2025

Building APIs using FastAPI

  • FastAPI Getting Started
  • Setting up the project Refer Here
  • A simple code in main.py
from fastapi import FastAPI


app = FastAPI(
    title="Hello Library",
    summary="Getting started with FastAPI",
    version="1.0.0")

@app.get("/")
def home() -> str:
    return "Welcome to Library"

# if __name__ == "__main__":
#     app


  • For debugging watch classroom video.

Adding Books Resource

  • Overview

| Endpoint | Method | Description | Request Body | Response |
| —————– | ———- | ——————————- | ——————————————- | ———————— |
| /api/books | GET | Get list of all books | Query: ?title=java&author=gosling | 200 OK – List of books |
| /api/books/{id} | GET | Get details of a single book | — | 200 OK – Book info |
| /api/books | POST | Add a new book (Librarian only) | { title, author, isbn, category, copies } | 201 Created |
| /api/books/{id} | PUT | Update book details | { title, author, category, copies } | 200 OK |
| /api/books/{id} | DELETE | Remove book (Librarian only) | — | 204 No Content |

Models in FastAPI

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading