first commit

This commit is contained in:
Ashim Kumar
2026-02-20 13:53:36 +06:00
commit 8e02b9ad09
35 changed files with 11059 additions and 0 deletions

61
routes/main_routes.py Normal file
View File

@@ -0,0 +1,61 @@
# routes/main_routes.py - Main Application Routes
import os
from flask import Blueprint, jsonify, send_from_directory, session
from config import DATABASE, VOICES
from auth import login_required, get_current_user
main_bp = Blueprint('main', __name__)
@main_bp.route('/')
@login_required
def index():
"""Serve main application page."""
return send_from_directory('templates', 'index.html')
@main_bp.route('/static/<path:filename>')
def serve_static(filename):
"""Serve static files."""
return send_from_directory('static', filename)
@main_bp.route('/api/voices', methods=['GET'])
@login_required
def get_voices():
"""Get available TTS voices."""
return jsonify({'voices': VOICES})
@main_bp.route('/api/stats', methods=['GET'])
@login_required
def get_stats():
"""Get database statistics."""
from db import get_db
db = get_db()
cursor = db.cursor()
cursor.execute('SELECT COUNT(*) as count FROM projects')
project_count = cursor.fetchone()['count']
cursor.execute('SELECT COUNT(*) as count FROM chapters')
chapter_count = cursor.fetchone()['count']
cursor.execute('SELECT COUNT(*) as count FROM markdown_blocks')
block_count = cursor.fetchone()['count']
cursor.execute('SELECT COUNT(*) as count FROM pdf_documents')
pdf_count = cursor.fetchone()['count']
db_size = os.path.getsize(DATABASE) if os.path.exists(DATABASE) else 0
return jsonify({
'projects': project_count,
'chapters': chapter_count,
'blocks': block_count,
'pdf_documents': pdf_count,
'database_size_mb': round(db_size / (1024 * 1024), 2)
})