3.10. Flask Template

The Flask Template is the shared foundation for building Flask applications — the application factory, routing, and project layout that both Flask API and Flask UI build on. It can’t be installed by itself; install one or both of those instead.

3.10.1. Automatic routing

Routes and views don’t need manual registration — drop a file in the right place and the Flask Template picks it up automatically:

  • A Blueprint or register() function under presentation/web/api/v1/routes/ (when flask_api is installed) is mounted under /api/v1.

  • A view function under presentation/web/ui/views/ (when flask_ui is installed) becomes a URL rule.

  • Every .html file under presentation/web/ui/templates/pages/ (also flask_ui) becomes a static route.

3.10.2. Database integration

If SQLAlchemy is also installed, the Flask Template connects to it automatically on startup. Without it, the application still runs — just without persistence — rather than failing to start.

3.10.3. Development vs. production

By default, the application runs on Flask’s own development server. Setting environment = "production" in config/app.toml switches it to gunicorn instead — a production-grade WSGI server — with no other changes needed. Either way, the server listens on port 5000 by default, overridable with the PORT environment variable.

This matters most in combination with the Docker Template: the same image works for local development and for a real deployment, just by changing that one configuration value before building.

3.10.4. Runner

The Flask Template ships one runner, in runners/main/flask.py:

  • python run flask start starts the application. In development it uses Flask’s server; with environment = "production" it uses gunicorn instead.