#!/bin/bash

# Set output HTML file name
HTML_FILE="index.html"

# Start HTML structure
cat <<EOF > "$HTML_FILE"
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Video Gallery</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #111;
            color: #eee;
            padding: 20px;
        }
        video {
            display: block;
            margin-bottom: 30px;
            max-width: 100%;
        }
    </style>
</head>
<body>
    <h1>Video Gallery</h1>
EOF

# Add video tags for each .mp4 or .avi file
for file in *.mp4 *.avi; do
    [ -e "$file" ] || continue  # Skip if no files match
    cat <<EOF >> "$HTML_FILE"
    <h2>$file</h2>
    <video controls>
        <source src="$file" type="video/$(echo "$file" | awk -F. '{print tolower($NF)}')">
        Your browser does not support the video tag.
    </video>
EOF
done

# End HTML
cat <<EOF >> "$HTML_FILE"
</body>
</html>
EOF

echo "Generated $HTML_FILE"

# Start Python HTTP server on port 8888
echo "Starting HTTP server on http://localhost:8888"
#python3 -m http.server 8888
