Add dynamic features: database models, authentication, and admin dashboard
This commit is contained in:
59
config.py
59
config.py
@@ -1,17 +1,58 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright Hersel Giannella
|
||||
# Enhanced Configuration with Database Settings
|
||||
|
||||
from pydantic_settings import BaseSettings
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
class Config(BaseSettings):
|
||||
APP_HOST: str = "127.0.0.1"
|
||||
APP_PORT: int = 5000
|
||||
DEBUG: bool = True
|
||||
SECRET_KEY: str = "default_secret_key"
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
class Config:
|
||||
# Flask/Quart Settings
|
||||
DEBUG = os.getenv('DEBUG', 'False').lower() == 'true'
|
||||
SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')
|
||||
|
||||
# Server Settings
|
||||
APP_HOST = os.getenv('APP_HOST', '0.0.0.0')
|
||||
APP_PORT = int(os.getenv('APP_PORT', '5000'))
|
||||
|
||||
# Database Settings
|
||||
DB_HOST = os.getenv('DB_HOST', 'localhost')
|
||||
DB_PORT = int(os.getenv('DB_PORT', '3306'))
|
||||
DB_USER = os.getenv('DB_USER', 'hersel_user')
|
||||
DB_PASSWORD = os.getenv('DB_PASSWORD', 'your_password_here')
|
||||
DB_NAME = os.getenv('DB_NAME', 'hersel_portfolio')
|
||||
|
||||
# Session Settings
|
||||
SESSION_PERMANENT = False
|
||||
SESSION_TYPE = 'filesystem'
|
||||
PERMANENT_SESSION_LIFETIME = 60 * 60 * 24 * 7 # 7 days
|
||||
|
||||
# Upload Settings
|
||||
UPLOAD_FOLDER = os.getenv('UPLOAD_FOLDER', 'static/uploads')
|
||||
MAX_CONTENT_LENGTH = int(os.getenv('MAX_CONTENT_LENGTH', '16777216')) # 16MB
|
||||
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'webp', 'pdf', 'txt', 'doc', 'docx'}
|
||||
|
||||
# Email Settings (for future use)
|
||||
MAIL_SERVER = os.getenv('MAIL_SERVER', 'localhost')
|
||||
MAIL_PORT = int(os.getenv('MAIL_PORT', '587'))
|
||||
MAIL_USE_TLS = os.getenv('MAIL_USE_TLS', 'True').lower() == 'true'
|
||||
MAIL_USERNAME = os.getenv('MAIL_USERNAME', '')
|
||||
MAIL_PASSWORD = os.getenv('MAIL_PASSWORD', '')
|
||||
|
||||
# Security Settings
|
||||
WTF_CSRF_ENABLED = True
|
||||
WTF_CSRF_TIME_LIMIT = None
|
||||
|
||||
# Pagination
|
||||
POSTS_PER_PAGE = int(os.getenv('POSTS_PER_PAGE', '10'))
|
||||
PROJECTS_PER_PAGE = int(os.getenv('PROJECTS_PER_PAGE', '12'))
|
||||
|
||||
# Cache Settings
|
||||
CACHE_TYPE = os.getenv('CACHE_TYPE', 'simple')
|
||||
CACHE_DEFAULT_TIMEOUT = int(os.getenv('CACHE_DEFAULT_TIMEOUT', '300'))
|
||||
|
||||
# Create config instance
|
||||
config = Config()
|
||||
|
||||
Reference in New Issue
Block a user