Quick and dirty boilerplate for a Flask app with Tailwind CSS and HTMX.
- Create a virtualenv using python 3.11+ (e.g. virtualenv .venv -p python3.11)
- Install requirements: source .venv/bin/activate && pip install -r requirements.txt
- Create an env.pyfile in the app's root directory and add the varSECRET_KEY: str = 'yourkeyhere'
- Download the relevant Tailwind CSS binary to the app's root directory and rename it tailwindcss: https://tailwindcss.com/blog/standalone-cli
- flask run --debug
- Set an env var PRODUCTION=1 to load the production config, rather than the default development config.
- Includes a basic Procfile and runtime.txt for Railway/Heroku deployment.
- Includes a basic Dockerfile for container-based deployments.
- Suggest using whitenoise for static files in prod: https://whitenoise.readthedocs.io/en/stable/flask.html
Base jinja2 template for inheritance. Includes static/css/dist.css and static/js/htmx.min.js by default.
Vars:
- title: strthe page title
- description: strthe meta description
Blocks:
- headhead tag content
- bodybody tag content
- scriptsbottom of the body tag for javascript
- ./twcompile.shis a shortcut script for Tailwind compilation (defaults input from- src/tailwindcss/input.cssand minified output to- static/css/dist.css). Get a binary here: https://tailwindcss.com/blog/standalone-cli
- The env.pyfile in the app root directory is required for secrets. This is loaded byconfig.pyduring app creation, and is used by theDevelopmentConfigclass.
- App is set up with a basic blueprint (front_page/for front page views).
- If you need access to the app object, avoid circular imports with from flask import current_app.
- Yes I've included jquery 3.7.1 in static/js. No you cannot stop me.