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:

    python run.py
    
  • 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.2.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.2-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flasksecforge-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 41f5cd6def07ffdc8e21631b774e37c54a433fbd7331a67d393fbd082e124da8
MD5 50927a0b1a60dcfe2f2f737fa9b644be
BLAKE2b-256 e4bdf0de8a95dc037ac54cd9d129ea48a414cb3644470de5fe172a887352b97a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flasksecforge-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e79e9c2535b314105bd2240e19653e14a223a700877b56247569f4a20fd0285f
MD5 cd34d147350579226032be4cd09631f4
BLAKE2b-256 364cdf92232cc0140004a54ee3688f2c2b0835100666f152a22b48adc04f9697

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