Deployment¶
The application can be deployed to any platform that supports Python WSGI applications. This guide covers deployment to Render and general production considerations.
Render¶
The repository includes a render.yaml blueprint for one-click deployment.
Fork or clone the repository to your GitHub account.
Create a new Web Service on Render and connect it to your repository.
Set the following environment variables in the Render dashboard:
Variable
Value
FLASK_SECRET_KEYA random string (e.g., output of
python -c "import secrets; print(secrets.token_hex(32))")URAND_CONFIG_FILEconfig-demo.yaml(or your own config file)URAND_STUDY_NAMEMust match a top-level key in your config YAML
DEMO_MODEtrueto bypass OAuth (demo only)GOOGLE_OAUTH_CLIENT_IDYour OAuth client ID (production)
GOOGLE_OAUTH_CLIENT_SECRETYour OAuth client secret (production)
Render will automatically build and deploy. The start command is:
gunicorn urand_gui.app:app
Demo Mode¶
Setting DEMO_MODE=true bypasses Google OAuth and automatically logs in
all visitors as a pre-seeded demo user. This is intended for public
demonstrations only — do not use demo mode in production.
To seed the demo database with sample participants:
flask init-demo
This creates 25 participants with randomized factor levels and treatment assignments, spread across several months for a realistic enrollment timeline.
Production Considerations¶
Use a persistent database. The default SQLite file is suitable for single-server deployments. For multi-server setups, use PostgreSQL.
Set a strong
FLASK_SECRET_KEY.Restrict OAuth users. Only registered users (added via
flask add_user) can access the web interface.Use HTTPS. Platforms like Render provide this automatically.
Back up your database regularly — it contains all randomization history.