Skip to main content

Scaffold a Flask‑secure boilerplate API.

Project description

🔐 FlaskSecForge – Production‑Ready Flask API Boilerplate Generator

PyPI version License: MIT

Quick Start

  1. Install the CLI tool:
    pip install flasksecforge
    
  2. Generate a new Flask API project:
    flasksecforge <your_project>
    

✨ Overview & Goals

FlaskSecForge scaffolds a secure, production‑ready Flask REST API with:

  • Environment Configuration for development & production
  • Structured Logging & error handling
  • JWT Authentication, CORS, and input validation
  • Database‑agnostic support (SQLite, PostgreSQL, MySQL, SQL Server)
  • Modular Blueprints (Auth, Users, Items)
  • Example Endpoints (Health check, Signup/Login, User Profile, CRUD)

📂 Directory Structure

<your_project>/
├── .env                  # Environment variables
├── requirements.txt      # Python dependencies
├── run.py                # Application entry point
├── config.py             # Config classes (Dev/Prod)
├── gunicorn.conf.py      # Production server settings
├── app/                  # Application package
│   ├── __init__.py       # App factory
│   ├── extensions.py     # DB, Migrate, JWT, CORS
│   ├── models.py         # SQLAlchemy models
│   ├── schemas.py        # Marshmallow schemas
│   ├── blueprints/       # Blueprint modules
│   │   ├── auth/         # Auth (register/login)
│   │   ├── users/        # Protected user routes
│   │   └── items/        # CRUD sample resource
│   └── utils.py          # Helpers & error handlers
└── logs/                 # Generated log files

Each folder and file follows a clear separation of concerns, making customization and extension straightforward.


🔧 Installation & Setup

  1. Create and activate a virtual environment:
    python3 -m venv venv
    source venv/bin/activate
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Configure your environment variables in .env:
    FLASK_ENV=development
    SECRET_KEY=<your_secret>
    JWT_SECRET_KEY=<your_jwt_secret>
    DATABASE_URL=sqlite:///data.db  # or your preferred DB URL
    

🚀 Usage

  • Run migrations:

    flask db init
    flask db migrate
    flask db upgrade
    
  • Start locally:

    flask run
    
  • Deploy with Gunicorn:

    gunicorn -c gunicorn.conf.py run:app
    

📖 Available Endpoints

Method Endpoint Description
GET /health Health check
POST /auth/register Register new user
POST /auth/login Obtain JWT token
GET /users/profile Get current user info
GET /items/ List all items
POST /items/ Create a new item
PUT /items/<id> Update an existing item
DELETE /items/<id> Delete an item

🛡️ Security & Best Practices

  • Keep SECRET_KEY and JWT_SECRET_KEY confidential
  • Use HTTPS in production
  • Validate and sanitize all user inputs
  • Rotate tokens and secrets regularly

🤝 Contributing & Support

Pull requests, issues, and feedback are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flasksecforge-0.1.3.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flasksecforge-0.1.3-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file flasksecforge-0.1.3.tar.gz.

File metadata

  • Download URL: flasksecforge-0.1.3.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for flasksecforge-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8a3535513e7fb15542bc26b854ea1cc6db7e4aba3d5e3decb600bf0c0acc168d
MD5 1c5f4a7dd36439200648e85dca9a1eee
BLAKE2b-256 4dcdea6dca75425436eb5f8ac6ed3f50d0fee536785ce40bfd054a1e0e1ca60a

See more details on using hashes here.

File details

Details for the file flasksecforge-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: flasksecforge-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for flasksecforge-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 11cc2bec7ac43ea6d44bc76f3a7961dba7ffe520bda04ea5ec354eb440c7ee67
MD5 bb774bb4f80284b2db1342efecf419c3
BLAKE2b-256 aa77a03620620e0c03446016d76664dbda8cf8d20aea918b8c296713c26cd689

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page