kamau1's picture
Iniital Commit
74de430

Templates Directory

This directory contains Jinja2 HTML templates for the SwiftOps API.

Structure

templates/
├── base.html       # Base template with common layout
└── index.html      # Landing page template

Usage

Templates are rendered using FastAPI's Jinja2Templates:

from fastapi.templating import Jinja2Templates

templates = Jinja2Templates(directory="templates")

@router.get("/")
async def index(request: Request):
    return templates.TemplateResponse("index.html", {
        "request": request,
        "app_name": "SwiftOps API"
    })

Adding New Templates

  1. Create a new HTML file in this directory
  2. Extend base.html for consistent layout:
{% extends "base.html" %}

{% block title %}Your Page Title{% endblock %}

{% block content %}
    <!-- Your content here -->
{% endblock %}
  1. Add a route in app/api/v1/pages.py

Template Variables

Common variables available in templates:

  • app_name - Application name
  • app_version - Current version
  • app_description - Short description
  • current_year - Current year for copyright
  • github_url - GitHub repository URL
  • endpoints - List of available endpoints

Styling

CSS is located in static/css/main.css and automatically supports:

  • Light/Dark mode (system preference)
  • Responsive design
  • Smooth animations