> Source URL: /unit-3/project-paths/duward-a/duward-a-2026-04-28-render-deploy.guide
# Duward A — Render Deploy Guide

**Project:** GPT Workout Planner  
**Repo:** `final-project-angldu6`  
**Goal:** Put your mobile-friendly Flask workout planner online for Demo Day.

This guide is tailored to your current repo. Your app has `app.py`, `planner.py`, `workouts/options.json`, `workouts/history.json`, templates, `pyproject.toml`, and `uv.lock`. It needs `gunicorn`, an OpenAI environment variable, and `render.yaml`.

---

## Before You Start

Make sure the app works locally:

```bash
uv sync
uv run flask --app app run --debug
```

Open the preview, submit a goal like `build muscle`, choose a location, and confirm a workout plan appears.

---

## Step 1 — Add the Production Server

Render should run your Flask app with `gunicorn`.

```bash
uv add gunicorn
```

This updates `pyproject.toml` and `uv.lock`.

---

## Step 2 — Add `.env.example`

Your app uses `OpenAI()` after `load_dotenv()`, so Render needs this environment variable:

```text
OPENAI_API_KEY
```

Create `.env.example` at the project root:

```text
OPENAI_API_KEY=
```

Keep your real `.env` file private. Do not commit the actual key.

---

## Step 3 — Create `render.yaml`

Create a new file at the project root named `render.yaml`:

```yaml
services:
  - type: web
    name: gpt-workout-planner
    env: python
    plan: free
    buildCommand: uv sync --frozen && uv cache prune --ci
    startCommand: uv run gunicorn app:app
    autoDeploy: true
    envVars:
      - key: OPENAI_API_KEY
        sync: false
```

Your `workouts/options.json` file is committed, so Render can load the same workout choices as your local app.

---

## Step 4 — Commit and Push

In Source Control, stage and commit:

- `pyproject.toml`
- `uv.lock`
- `.env.example`
- `render.yaml`

Use a message like:

```text
add render deploy config
```

Then click **Sync Changes**.

---

## Step 5 — Create the Render Service

1. Go to [render.com](https://render.com) and sign in with GitHub.
2. Click **New +** → **Web Service**.
3. Connect `final-project-angldu6`.
4. Confirm these settings:
   - **Environment:** `Python`
   - **Build Command:** `uv sync --frozen && uv cache prune --ci`
   - **Start Command:** `uv run gunicorn app:app`
   - **Plan:** `Free`
5. In **Environment Variables**, add your real `OPENAI_API_KEY`.
6. Click **Create Web Service**.

---

## Step 6 — Test the Live Site

When Render finishes, open the live URL and test the core flow:

1. Submit a clear goal like `build muscle`.
2. Try both location choices.
3. Confirm the generated plan appears.
4. Open the previous workouts page.
5. Try clearing history.

If the app crashes after submit, check that `OPENAI_API_KEY` is set in Render.

---

## Demo Day Notes

Your app writes recent workout history to `workouts/history.json`. On Render's free tier, file changes made by visitors can disappear after a redeploy. For demo day, this is fine: open the app before presenting, generate one or two fresh workouts, and show the history from that live session.


---

## Backlinks

The following sources link to this document:

- [April 28 — Render deploy](/unit-3/project-paths/projects.path.llm.md)
- [April 28 -- Render deploy](/unit-3/project-paths/duward-a/duward-a.path.llm.md)
- [April 28 - Render deploy](/unit-3/projects/showcase/duward-a.project.llm.md)
