← Back to all products

Feature Flags

$19

Feature flag system with boolean flags, percentage rollouts, user targeting, and A/B tests.

📁 9 files
PythonMarkdown

📄 Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample

📁 File Structure 9 files

feature-flags/ ├── LICENSE ├── README.md ├── examples/ │ └── basic_example.py ├── free-sample.zip ├── guide/ │ ├── 01_features.md │ ├── 02_quick-start.md │ └── 03_project-structure.md ├── index.html └── src/ └── main.py

📖 Documentation Preview README excerpt

Feature Flags

A Python feature flag system for SaaS applications. Supports boolean flags, percentage rollouts, user targeting rules, A/B testing with deterministic variant assignment, kill switches, and scheduled activations — all built on Python's standard library.

Features

  • Boolean flags — Simple on/off toggles for any feature
  • Percentage rollouts — Gradual rollout via deterministic hashing (consistent per user)
  • User targeting — Rules matching on user attributes (plan, email, role, etc.)
  • A/B testing — Multiple variants with consistent assignment per user
  • Kill switch — Emergency one-call disable for any flag
  • Scheduled flags — Auto-enable/disable at specified times
  • Match operatorseq, neq, contains, in, gt, lt
  • Evaluate all — Bootstrap all flags for a user in one call (great for frontends)
  • JSON persistence — Save/load flag configs and evaluation logs

Requirements

  • Python 3.10+
  • No external dependencies (stdlib only)

Quick Start


# Start with demo flags
python src/main.py --init-demo

# Custom port
python src/main.py --port 8003

Then try the API:


# List all flags
curl http://localhost:8003/api/flags

# Evaluate a flag for a user
curl -X POST http://localhost:8003/api/flags/new_dashboard/evaluate \
  -H "Content-Type: application/json" \
  -d '{"context": {"user_id": "user_123", "plan": "pro", "email": "user@example.com"}}'

# Kill switch
curl -X POST http://localhost:8003/api/flags/new_dashboard/kill

# Revive
curl -X POST http://localhost:8003/api/flags/new_dashboard/revive

API Endpoints

MethodPathDescription
GET/api/flagsList all flags
POST/api/flagsCreate a new flag
POST/api/flags/:key/evaluateEvaluate flag for a user context
POST/api/flags/:key/evaluate-allEvaluate ALL flags for a user
POST/api/flags/:key/killEmergency kill switch
POST/api/flags/:key/reviveRe-enable a killed flag

... continues with setup instructions, usage examples, and more.

📄 Code Sample .py preview

src/main.py #!/usr/bin/env python3 """ Feature Flags — Runtime Feature Flag System ============================================= A complete feature flag system for SaaS applications. Supports boolean flags, percentage rollouts, user targeting, A/B testing, kill switches, and scheduled activations — all without external dependencies. Drop this into any Python project to control feature visibility at runtime without redeploying. Zero dependencies. Just run: python3 main.py Part of the SaaS Starter collection by DataNest. License: MIT """ from __future__ import annotations import argparse import hashlib import json import logging import os import time import uuid from dataclasses import asdict, dataclass, field from datetime import datetime, timezone, timedelta from http.server import BaseHTTPRequestHandler, HTTPServer from pathlib import Path from typing import Any, Optional from urllib.parse import parse_qs, urlparse # --------------------------------------------------------------------------- # Configuration # --------------------------------------------------------------------------- DEFAULT_HOST = "0.0.0.0" DEFAULT_PORT = 8003 DATA_DIR = Path("./flags-data") logging.basicConfig( level=logging.INFO, format="%(asctime)s [%(levelname)s] %(name)s — %(message)s", datefmt="%Y-%m-%dT%H:%M:%S", ) logger = logging.getLogger("feature-flags") # ... 464 more lines ...
Buy Now — $19 Back to Products