65 lines
No EOL
1.5 KiB
Markdown
65 lines
No EOL
1.5 KiB
Markdown
# Flask Base Application
|
|
|
|
A basic Flask application with user configuration and database support.
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
├── app/
|
|
│ ├── __init__.py # Application factory and extensions
|
|
│ ├── routes.py # Route definitions
|
|
│ ├── models.py # Database models
|
|
│ └── utils.py # Utility functions
|
|
├── tests/
|
|
│ ├── __init__.py
|
|
│ └── test_app.py # Unit tests
|
|
├── config.py # Configuration classes
|
|
├── main.py # Application entry point
|
|
├── requirements.txt # Python dependencies
|
|
├── .env.example # Environment variables template
|
|
└── README.md
|
|
```
|
|
|
|
## Setup
|
|
|
|
1. **Install dependencies:**
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. **Configure environment:**
|
|
```bash
|
|
cp .env.example .env
|
|
# Edit .env with your own settings
|
|
```
|
|
|
|
3. **Run the application:**
|
|
```bash
|
|
python main.py
|
|
```
|
|
|
|
Or using Flask CLI:
|
|
```bash
|
|
flask run
|
|
```
|
|
|
|
## Configuration
|
|
|
|
The app supports multiple environments via configuration classes in `config.py`:
|
|
|
|
- **Development** (`FLASK_ENV=development`) - Default, with debug enabled
|
|
- **Testing** (`FLASK_ENV=testing`) - In-memory database, CSRF disabled
|
|
- **Production** (`FLASK_ENV=production`) - Debug disabled
|
|
|
|
## Running Tests
|
|
|
|
```bash
|
|
python -m pytest tests/
|
|
# or
|
|
python -m unittest discover tests
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /` - Home page
|
|
- `GET /health` - Health check endpoint |