import logging
from flask import Flask, render_template, request
from gunicorn.app.base import BaseApplication

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

app = Flask(__name__)

@app.route("/", methods=["GET"])
def root_route():
    return render_template("template.html", countdown_time="0")

@app.route("/start_timer", methods=["POST"])
def start_timer():
    countdown_time = request.form.get("countdown_time", "0")
    try:
        countdown_time = int(countdown_time) * 60  # Convert minutes to seconds
    except ValueError:
        countdown_time = 0
    return render_template("template.html", countdown_time=countdown_time)
    return render_template("template.html", countdown_time=countdown_time)

class StandaloneApplication(BaseApplication):

About this template

Countdown Master: A simple countdown timer app with customizable time settings and start/stop functionality.

Introduction to the Countdown Master Template

Welcome to the Countdown Master template guide. This template is designed to help you create a simple yet effective countdown timer web application using Flask, HTML, and JavaScript. The application allows users to set a timer, start it, and see the countdown in real time. It also includes a reset and stop functionality for the timer. This guide will walk you through the steps to get your countdown timer app up and running on the Lazy platform.

Getting Started

To begin using the Countdown Master template, click on "Start with this Template" in the Lazy Builder interface. This will pre-populate the code in the Lazy Builder, so you won't need to copy or paste any code manually.

Test: Deploying the App

Once you have the template loaded, press the "Test" button to start the deployment of your app. The Lazy CLI will handle the deployment process, and you won't need to worry about installing any libraries or setting up your environment.

Using the Countdown Master App

After deployment, Lazy will provide you with a dedicated server link to access your countdown timer app. Here's how to use the interface:

  • Enter the time in minutes in the input field labeled "Enter time in minutes".
  • Click the "Start" button to begin the countdown. The timer will display the countdown in minutes and seconds.
  • If you wish to stop the timer, click the "Stop" button.
  • To reset the timer and clear the input, click the "Reset" button.

The JavaScript code provided in the template will handle the countdown functionality and update the display in real time.

Integrating the App

If you wish to integrate the Countdown Master app into an external tool or service, you may need to use the server link provided by Lazy. For example, if you want to embed the countdown timer into another web page, you can use an iframe with the server link as the source.

Here's a sample code snippet to embed the countdown timer:


<iframe src="YOUR_SERVER_LINK" width="300" height="200"></iframe>

Replace "YOUR_SERVER_LINK" with the actual link provided by Lazy.

If you need to interact with the app's backend for any reason, you can use the server link to send POST requests to the "/start_timer" endpoint to programmatically start the timer.

Here's a sample POST request you might send to the server:


POST /start_timer HTTP/1.1
Host: YOUR_SERVER_LINK
Content-Type: application/x-www-form-urlencoded

countdown_time=15

This request would start a 15-minute timer. Replace "YOUR_SERVER_LINK" with the actual link provided by Lazy.

Remember, the Lazy platform handles all the deployment details, so you can focus on building and integrating your application. Enjoy creating with the Countdown Master template!

Category
Technology
Last published
July 26, 2024

More templates like this

SecureUserAuthenticator

Develop a secure User Authentication system for users to register, log in, and manage their profiles, laying the foundation for user-specific data management and permissions in the CMS.

Laravel
Python
Flask
Javascript

Simple Multiplayer Telegram game

This app is a simple frontend for a game where users can upvote and downvote the most popular word in their country, learn about the flags of other countries, and view what other people voted for on a leaderboard.

Telegram
Python
Javascript

MP3ify: Youtube to MP3 Converter

A web application that allows users to download YouTube videos from URLs and provides the option to convert them to MP3 format.

Python
Flask
Home
/
Countdown Master