Major Changes: - Migrated web framework from Quart (async) to Flask (sync) - Added MariaDB database integration with SQLAlchemy ORM - Implemented dynamic content management for portfolio New Features: - Database models for Profile, Skills, Projects, ProjectTags, and SocialLinks - RESTful API endpoints for CRUD operations on all entities - Database initialization script (init_db.py) with sample data - Docker Compose configuration with MariaDB service Modified Files: - app.py: Replaced Quart with Flask, added database initialization - config.py: Added database configuration with environment variables - routes/home.py: Converted async to sync, added database queries - requirements.txt: Replaced Quart/Hypercorn with Flask/Gunicorn, added Flask-SQLAlchemy and PyMySQL - docker-compose.yml: Added MariaDB service with health checks - templates/: Updated all templates to use dynamic data from database with Jinja2 - .env.example: Added database configuration variables - README.md: Complete rewrite with new setup instructions and API documentation New Files: - models.py: SQLAlchemy models for all database entities - init_db.py: Database initialization script - routes/api.py: REST API endpoints for content management Benefits: - Simplified architecture (sync vs async) - Better ecosystem compatibility - Dynamic content management via database - Easy content updates through REST API - Improved deployment with standard WSGI server (Gunicorn)
27 lines
843 B
Python
27 lines
843 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright Hersel Giannella
|
|
|
|
from flask import Blueprint, render_template
|
|
from models import Profile, Skill, Project, SocialLink
|
|
|
|
route_home = Blueprint('route_home', __name__)
|
|
|
|
@route_home.route('/')
|
|
def home():
|
|
"""Render home page with dynamic data from database"""
|
|
# Fetch all data from database
|
|
profile = Profile.query.first()
|
|
skills = Skill.query.filter_by(is_active=True).order_by(Skill.display_order).all()
|
|
projects = Project.query.filter_by(is_published=True).order_by(Project.display_order).all()
|
|
social_links = SocialLink.query.filter_by(is_active=True).order_by(SocialLink.display_order).all()
|
|
|
|
return render_template(
|
|
'index.html',
|
|
profile=profile,
|
|
skills=skills,
|
|
projects=projects,
|
|
social_links=social_links
|
|
)
|