This repository contains a template for a Flask project, including configurations for development and production environments, logging, error handling, and a structured application setup with blueprints.
To get a local copy up and running, follow these simple steps.
- Python 3.10
- pip (Python package installer)
-
Clone the repo
git clone https://github.com/yourusername/your-repo.git cd your-repo
-
Create and activate a virtual environment
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies
pip install -r requirements.txt
The application configuration is managed using environment variables. Create a .env
file in the root directory to
specify these variables.
HOST
: The host address for the Flask applicationPORT
: The port for the Flask applicationDEBUG
: Enable/disable debug mode (default:True
)DB_HOST
: The host address for the databaseDB_NAME
: The name of the databaseDB_USER
: The database userDB_PASSWORD
: The database passwordDB_PORT
: The database port
To run the application in development mode, use the following command:
python main.py
This will start the Flask application with the settings specified in your .env file.
To run the application in production mode, use gunicorn. It is a Python WSGI HTTP Server for UNIX.
gunicorn -w 4 --bind 127.0.0.1:8080 'wsgi:create_app'
This command starts the application with 4 worker processes, binding to the specified address and port.