feat: Initialize frontend with React, Vite, and Tailwind CSS
- Set up main entry point for React application. - Create About, Home, NotFound, Privacy, and Terms pages with SEO support. - Implement API service for file uploads and task management. - Add global styles using Tailwind CSS. - Create utility functions for SEO and text processing. - Configure Vite for development and production builds. - Set up Nginx configuration for serving frontend and backend. - Add scripts for cleanup of expired files and sitemap generation. - Implement deployment script for production environment.
This commit is contained in:
31
backend/app/utils/cleanup.py
Normal file
31
backend/app/utils/cleanup.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Scheduled cleanup of expired temporary files."""
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
|
||||
from flask import current_app
|
||||
|
||||
|
||||
def cleanup_expired_files():
|
||||
"""Remove files older than FILE_EXPIRY_SECONDS from upload/output dirs."""
|
||||
expiry = current_app.config.get("FILE_EXPIRY_SECONDS", 1800)
|
||||
now = time.time()
|
||||
removed_count = 0
|
||||
|
||||
for folder_key in ["UPLOAD_FOLDER", "OUTPUT_FOLDER"]:
|
||||
folder = current_app.config.get(folder_key)
|
||||
if not folder or not os.path.exists(folder):
|
||||
continue
|
||||
|
||||
for task_dir_name in os.listdir(folder):
|
||||
task_dir = os.path.join(folder, task_dir_name)
|
||||
if not os.path.isdir(task_dir):
|
||||
continue
|
||||
|
||||
# Check directory age based on modification time
|
||||
dir_mtime = os.path.getmtime(task_dir)
|
||||
if now - dir_mtime > expiry:
|
||||
shutil.rmtree(task_dir, ignore_errors=True)
|
||||
removed_count += 1
|
||||
|
||||
return removed_count
|
||||
Reference in New Issue
Block a user