Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.22 KB

File metadata and controls

51 lines (37 loc) · 1.22 KB

Module 1: Backend Fundamentals with FastAPI

This folder contains the practical work for Module 1 of the FastAPI tutorial series. The exercises and examples here introduce the basics of building backend applications using FastAPI and Python.

Getting Started

  1. Create a virtual environment:

    python -m venv .venv

    Activate the virtual environment:

    • On macOS/Linux:
    source .venv/bin/activate 

    On Windows use .venv\Scripts\activate

  2. Install dependencies:

    pip install fastapi uvicorn
  3. Create a file named main.py and add the following code:

    from fastapi import FastAPI
    
    app = FastAPI()
    
    # Hello FastAPI Project
    @app.get("/")
    def read_root():
        return {"message": "Hello, FastAPI!"}
  4. Run the FastAPI app:

    uvicorn main:app --reload
  5. Open your browser at http://127.0.0.1:8000 to access the API.

Learning Objectives

  • Understand FastAPI project structure
  • Create basic API endpoints
  • Run and test a FastAPI application

For more information, see the FastAPI documentation.