from django.shortcuts import render

def home(request):
    """
    Render the landing page and handle the content generation form.
    """
    context = {}
    if request.method == 'POST':
        topic = request.POST.get('topic', '').strip()
        context['topic'] = topic

        if not topic:
            context['error'] = 'Please enter a video topic.'
        else:
            # Mock data for demonstration purposes
            context['results'] = {
                'title': f'🚀 The Ultimate Guide to {topic.title()} in 2025 | SEO Secrets',
                'hashtags': ['#' + ''.join(word.capitalize() for word in topic.split()), '#YouTube', '#SEO', '#Viral', '#ContentCreation'],
                'tags': [topic, f'{topic} tutorial`, `learn {topic}', 'how to', '2025', 'SEO tips', 'viral video']
            }
            context['meta_description'] = f'Get the best viral tags, hashtags, and titles for your video about {topic}. Boost your views with our AI-powered suggestions.'
            context['slug'] = f'viral-guide-{topic.lower().replace(" ", "-")}'

    return render(request, "core/index.html", context)
