Deployment
Hands-on lab with starter code you can copy + run, and guided steps to produce the artifact for this module.
Setup
- Open a fresh terminal in a new folder, e.g.
mkdir lab-9 && cd lab-9. - Create a Python 3.11 venv:
python -m venv .venv && source .venv/bin/activate. - Install the dependencies noted on each starter snippet (the small pip install … line above the code).
- Copy each starter into a file with the suggested name, then run it and capture the output.
Starter code
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Ask(BaseModel):
question: str
@app.post("/ask")
def ask(body: Ask):
return {"answer": react(body.question)}
# uvicorn server:app --host 0.0.0.0 --port 8080python 09_01_lab.py# Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8080"]bash 09_02_lab.shGuided steps
Work through each step in order. Stop when your output matches the expected artifact — then push your work to your lab folder.
- 1FastAPI wrapper
Do — Expose your agent at POST /ask. Return JSON {answer, steps}.
Expected artifact — `curl -X POST localhost:8080/ask -d '{"question":"..."}'` returns valid JSON.
Run free: - 2Dockerize
Do — Write a Dockerfile and run the container locally. Confirm the endpoint works from the host.
Expected artifact — `docker run -p 8080:8080 my-agent` serves /ask successfully.
Run free: - 3Smoke + health checks
Do — Add /healthz and a smoke test script that POSTs 3 known-good prompts.
Expected artifact — smoke.sh exits 0 when service is healthy and answers are sane.
Run free:
Authoritative sources
Independent primary sources used to check and corroborate the guidance on this page.
- NIST National Initiative for Cybersecurity Education (NICE)
US national framework for cybersecurity work roles and competencies.
- Financial Action Task Force (FATF)
Global AML/CFT standards referenced by financial-crime curricula.
- FBI Internet Crime Complaint Center — Annual Reports
Primary loss and typology data used in fraud-investigation training.
- US Federal Trade Commission — Consumer Sentinel Data Book
Official complaint statistics for teaching fraud trend analysis.
