🔐 FlaskSecForge – Production‑Ready Flask API Boilerplate Generator
- GitHub: https://github.com/reprompts/flasksecforge
- Community: https://dev.to/repromptsquest
- LinkedIn: https://www.linkedin.com/groups/14631875/
Quick Start
- Install the CLI tool:
pip install flasksecforge
- 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
- Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- 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_KEYandJWT_SECRET_KEYconfidential - Use HTTPS in production
- Validate and sanitize all user inputs
- Rotate tokens and secrets regularly
🤝 Contributing & Support
Pull requests, issues, and feedback are welcome!
Release files for flasksecforge 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flasksecforge-0.1.3.tar.gz | 11.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flasksecforge-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.8 kB
Release files / flasksecforge-0.1.3.tar.gz
| Download URL | flasksecforge-0.1.3.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a3535513e7fb15542bc26b854ea1cc6db7e4aba3d5e3decb600bf0c0acc168d
|
|
BLAKE2b-256 checksum How to use checksums |
4dcdea6dca75425436eb5f8ac6ed3f50d0fee536785ce40bfd054a1e0e1ca60a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.4
|
Release files / flasksecforge-0.1.3-py3-none-any.whl
| Download URL | flasksecforge-0.1.3-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11cc2bec7ac43ea6d44bc76f3a7961dba7ffe520bda04ea5ec354eb440c7ee67
|
|
BLAKE2b-256 checksum How to use checksums |
aa77a03620620e0c03446016d76664dbda8cf8d20aea918b8c296713c26cd689
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.4
|