A production-ready Flask application template with Docker support, security features, and best practices implemented.
- Flask REST API
- Docker support
- CORS enabled
- Security headers
- Logging system
- Health check endpoint
- Error handling
- Environment configuration
- Docker compose setup
- Python 3.11+
- Docker (optional)
- pip
-
Clone the repository:
git clone https://github.com/yourusername/flask-template.git cd flask-template -
Create and activate virtual environment:
| Variable | Description | Default |
|---|---|---|
| FLASK_ENV | Environment mode | dev |
| SECRET_KEY | App secret key | None |
| PORT | Application port | 5001 |
| Method | Endpoint | Description |
|---|---|---|
| GET | / | Root endpoint |
| GET | /health | Health check |
| GET | /time | Current time |
- Non-root user in Docker
- Security headers implemented
- CORS protection
- Error handling
- Logging system
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
-
Port already in use
sudo lsof -i :5001 # Find process using port sudo kill -9 <PID> # Kill process
-
Docker permission denied
sudo usermod -aG docker $USER # Add user to docker group newgrp docker # Activate changes
- Create and Activate a Virtual Environment (Optional but Recommended)
- python -m venv venv # Create a virtual environment
- source venv/bin/activate # Activate on macOS/Linux
- venv\Scripts\activate # Activate on Windows
- install requirments :
pip install -r requirements.txt
- export FLASK_APP=app.py # On macOS/Linux set FLASK_APP=app.py # On Windows
- flask run
- Run ./bin/run_cluster.sh
1- add access token (classic) 2- create flux folder and add (Kustomzation.yaml, git-repository.yaml) 3- update Kustomzation to use K8S/base deployement
flux bootstrap github
--owner=Mossaaba
--repository=flux-pyth
--branch=main
--path=flux
--personal
4- apply kustomization and source
kubectl apply -f flux/kustomization.yaml
kubectl apply -f flux/git-repository.yaml
5- check pods
kubectl get kustomizations kubectl get sources git
kubectl get pods -n flux-system kubectl get pods -n python-web-app-ns
flux reconcile source git flux-system flux reconcile kustomization python-web-app