loreal-video-optimizer/backend/api.php
DJP 129ea3ec1e Initial commit: Video Optimizer for L'Oréal
Complete video optimization tool with:
- 21 platform configurations (Meta, TikTok, YouTube, Pinterest, Snapchat, Amazon)
- FFmpeg-powered video conversion with H264, H265, and VP9 codecs
- Python Flask backend with REST API
- HTML/JS frontend with drag-drop interface
- Black + #FFC407 color scheme with Montserrat font
- Side-by-side video comparison player
- Filename auto-detection for platform and aspect ratio
- MAMP-compatible setup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 16:52:11 -04:00

76 lines
1.9 KiB
PHP

<?php
/**
* PHP Proxy for Python Flask Backend
* Use this when hosting frontend on MAMP
*/
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
// Handle preflight requests
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}
// Python backend URL
$PYTHON_BACKEND = 'http://localhost:5000/api';
// Get the endpoint from the request
$endpoint = isset($_GET['endpoint']) ? $_GET['endpoint'] : '';
// Build full URL
$url = $PYTHON_BACKEND . '/' . $endpoint;
// Initialize cURL
$ch = curl_init($url);
// Set options based on request method
$method = $_SERVER['REQUEST_METHOD'];
switch ($method) {
case 'GET':
curl_setopt($ch, CURLOPT_HTTPGET, true);
break;
case 'POST':
curl_setopt($ch, CURLOPT_POST, true);
// Check if it's a file upload
if (isset($_FILES['file'])) {
$file = $_FILES['file'];
$cfile = new CURLFile($file['tmp_name'], $file['type'], $file['name']);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['file' => $cfile]);
} else {
// JSON data
$json = file_get_contents('php://input');
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
}
break;
case 'DELETE':
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Execute request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
// Set response headers
http_response_code($httpCode);
if ($contentType) {
header('Content-Type: ' . $contentType);
}
// Output response
echo $response;
?>