A modern, secure Flask starter application with built-in authentication, SQLAlchemy integration, and a clean, responsive UI.
- User authentication system with Flask-Login
- SQLAlchemy database integration
- Secure password hashing
- Responsive Bootstrap 5 UI
- Form validation with WTForms
- Flash message support
- Testing setup with pytest
- Development and Production configurations
- Environment variable support
- Custom error handling
- Modern CSS with CSS variables
- Python 3.x
- pip (Python package manager)
-
Clone the repository:
git clone <repository-url> cd flask-login-starter
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the root directory and add your configuration:FLASK_ENV=development SECRET_KEY=your-secret-key DATABASE_URL=your-database-url # Required for production
- The application will automatically create a SQLite database in development mode
- To create an admin user, run:
python create_admin.py
To run the application in development mode, use:
flask runTo run the application in production mode, use:
gunicorn app:app --bind 0.0.0.0:$PORTRun the test suite using pytest:
pytestFor coverage report:
pytest --cov=appflask-login-starter/ ├── app.py # Application entry point ├── config.py # Configuration settings ├── models.py # Database models ├── forms.py # Form definitions ├── routes.py # Route handlers ├── requirements.txt # Project dependencies ├── static/ │ └── css/ # CSS stylesheets ├── templates/ │ ├── base.html # Base template │ ├── login.html # Login page │ └── index.html # Home page └── tests/ # Test directory
## Configuration
The application supports three environments:
- Development (default)
- Testing
- Production
Configuration is handled in `config.py` and can be extended based on requirements.
## Security Features
- Password hashing using Werkzeug
- CSRF protection with Flask-WTF
- Secure session handling
- Environment-based configurations
- SQL injection prevention through SQLAlchemy
## Contributing
1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request
## License
This project is licensed under the MIT License - see the LICENSE file for details.