This repository contains a small FastAPI application with user authentication.
- Sign in page
- SQLite database for storing users by default
- Optional PostgreSQL support via the
DATABASE_URLenvironment variable - Protected page that greets authenticated users
- Dark mode toggle available from the account settings page
- Random dog photo page for logged in users
- Nashville weather forecast including a detailed view
Run the setup script to create a virtual environment and install dependencies:
./setup.sh
source venv/bin/activateThe script configures SQLite for local development. If you prefer PostgreSQL, install Docker manually and set the DATABASE_URL environment variable accordingly.
Run the application:
uvicorn app.main:app --reloadRun tests:
PYTHONPATH=. pytestDATABASE_URL– SQLAlchemy connection string. Defaults tosqlite:///./test.dbif unset.TEST_DATABASE_URL– Optional connection string used by the test suite. If unset, the tests use an in-memory SQLite database.DEPLOY_HOST,DEPLOY_USER,DEPLOY_KEY– Secrets used by the deploy GitHub Actions workflow. Obtain these from the target server administrator.
A Dockerfile is provided for containerized deployment.
Build and run:
docker build -t codex-playground .
docker run -e DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres \
-p 8000:80 codex-playgroundTo keep the default SQLite database across container restarts, mount a host
directory and point DATABASE_URL to that location:
docker run -v $(pwd)/data:/data \
-e DATABASE_URL=sqlite:////data/test.db \
-p 8000:80 codex-playgroundThe example above expects a PostgreSQL instance reachable at the hostname db. For local development you can run a Postgres container with:
docker run --name db -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres:15Visit http://localhost:8000/login to sign in.