Skip to content

Releases: imvickykumar999/Django-Celery

CRUD Message

24 Jul 06:13
a4fe05c
Compare
Choose a tag to compare

⏭️ Skipped update: message is unchanged for chat_id

celery -A myproject worker --loglevel=info
celery -A myproject beat --loglevel=info
python manage.py runserver 0.0.0.0:8000
image image image image

Telegram Cron

17 Jul 07:44
c142cb0
Compare
Choose a tag to compare
image image image image image

views.py

# from django.http import JsonResponse
from .tasks import test_celery_task
from django.shortcuts import render

def trigger_task(request):
    test_celery_task.delay()
    # return JsonResponse({'status': 'Task triggered'})
    return render(request, 'index.html')

settings.py

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            '/root/newsletter/main/templates',
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Celery Scheduled Task</title>
    <style>
        /* Fullscreen video container */
        .video-container {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%); /* Center the div in the middle of the screen */
            width: 100%; /* Set the width to 100% of the viewport */
            height: 100%; /* Set the height to 100% of the viewport */
            z-index: -1; /* Make sure the video container is behind the content */
            overflow: hidden; /* Prevent video overflow */
        }

        /* Video iframe styling */
        .video-container iframe {
            width: 100%;
            height: 100%;
            border: 0;
        }

        /* Content styling */
        .content {
            position: relative;
            z-index: 1;
            color: white;
            text-align: center;
            padding: 50px;
        }

        /* Media query for small devices (portrait mode on mobile) */
        @media (max-width: 768px) {
            .video-container {
                width: 100vh; /* Use height as the width on mobile */
                height: 100vw; /* Use width as the height on mobile */
                top: 50%; /* Vertically center the container */
                left: 50%; /* Horizontally center the container */
                transform: translate(-50%, -50%) rotate(90deg); /* Rotate and keep it centered */
                overflow: hidden; /* Prevent overflow on rotation */
            }

            .video-container iframe {
                width: 100%; /* Ensure iframe fits the container */
                height: 100%; /* Ensure iframe height stays proportional */
            }

            .content {
                padding: 20px; /* Adjust padding for mobile */
            }
        }

    </style>
</head>
<body>

    <!-- Video container with iframe -->
    <div class="video-container">
        <iframe src="https://www.youtube.com/embed/Nz_Gcc-5znY?start=32&autoplay=1&mute=1&loop=1&playlist=Nz_Gcc-5znY" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
    </div>

    <!-- Your page content -->
    <div class="content">
    </div>

</body>
</html>