Files
structured-website-builder-…/skills-scripts/contact-form-deployment.md
T
2026-06-09 11:57:54 -06:00

1.2 KiB

Contact Form Deployment

The website form posts to /api/contact. The handler is a small FastAPI app in api/contact_app.py and sends mail through Postmark SMTP.

VM Packages

Install Python and the contact API dependencies inside the container or Python runtime that will serve the API:

python3 -m pip install -r requirements-contact-api.txt

The runtime needs these environment variables. Do not commit their values:

SMTP_HOST=smtp.postmarkapp.com
SMTP_PORT=587
SMTP_USER=<postmark-server-token-or-smtp-user>
SMTP_PASSWORD=<postmark-server-token-or-smtp-password>
CONTACT_TO_EMAIL=<where messages should go>
CONTACT_FROM_EMAIL=<verified Postmark sender address>
RECAPTCHA_SECRET_KEY=<google-recaptcha-secret-key>

Run Command

Run the API on an internal port, then route /api/contact to it from the existing container/Caddy setup:

uvicorn api.contact_app:app --host 0.0.0.0 --port 8091

Health check:

curl http://localhost:8091/api/contact/healthz

The public static site can continue to be served as it is now. The only deployment requirement is that requests for /api/contact and /api/contact/healthz reach the FastAPI process.