Birth & Death Date Predictor App | Built with Flask + Gemini LLM 🧬⚙️: Project

🔮 Ever wondered how long someone has lived—or might live—based on actuarial data?

In this tutorial, I demo a Birth & Expected Death Calculator web app, fully powered by Google Gemini large‑language model and a lightweight Flask backend.

Birth & Death Date Predictor App

Main Features

  • 📅 Age Calculator – Instant years, months, days lived

  • 🧠 Life‑Expectancy Estimator – Gemini LLM suggests an expected lifespan using WHO datasets & country stats

VIDEO:

PROMPT:

"""

I wanted to create a age calculator app. Just collect Name, Date of Birth & Time (Optional). Create a funny and exiting flask app where it will show how many years, months, days , hours , minutes and seconds you have been born.
Based on their date of birth, show them the today's horoscope. For this you can use google gemini API key.
It can be used in any device. Adjust the canvas accordingly.
Show the running time that they have born..
Also show them to see the death calculator which is funny and give some death date based on their horoscope and show the years, months, days, hours, minutes and seconds left to die. In this case you can use a intense theme for the page.
Use Tailwind CSS theme.
Give me each code seperately
Generate code so that i can run on VS Code app.

"""



SOURCE CODEhttps://github.com/yempallyvamshi/birth_death_calculator


Here is google gemini output:

Explanation and Features:

  • app.py (Flask Backend):

    • Handles the web server logic.

    • calculate_age function: Computes the age in years, months, days, hours, minutes, and seconds. It also calculates total days, hours, minutes, and seconds for the "running time" display.

    • get_zodiac_sign function: Determines the zodiac sign based on the birth month and day.

    • calculate_death_date function: This is the "funny" part! It generates a random death date based on a base age and a slight adjustment influenced by the zodiac sign. Remember, this is purely for entertainment and not a real prediction.

    • Routes (/ and /death_calculator): Render the respective HTML templates and pass the calculated data.

  • index.html (Age & Horoscope Page):

    • User Input: Collects Name, Date of Birth, and optional Time of Birth.

    • Age Display: Shows the calculated age with a real-time counter updated every second using JavaScript.

    • Horoscope:

      • Uses the __api_key (which the Canvas environment will automatically inject) to call the Gemini API from the client-side JavaScript.

      • Fetches a concise daily horoscope based on the user's zodiac sign.

      • Includes a loading spinner while the horoscope is being fetched.

    • Navigation: A button to link to the "Death Calculator" page, passing the necessary user data as URL parameters.

    • Styling: Uses Tailwind CSS for a modern, clean, and responsive design with a calming background.

  • death_calculator.html (Death Calculator Page):

    • Intense Theme: Uses a darker background, red accents, and a "Creepster" font for headings to create an "intense" and humorous atmosphere.

    • Death Date Display: Shows the calculated funny death date.

    • Countdown: A real-time countdown in years, months, days, hours, minutes, and seconds until the "predicted" death date, updated every second via JavaScript.

    • Disclaimer: Clearly states that the calculation is for fun.

    • Navigation: A button to go back to the main age calculator page.

Key Points for the Gemini API:

  • In index.html, the apiKey variable in the JavaScript fetchHoroscope function is left as an empty string (const apiKey = "";). When you run this in the Canvas environment, it will automatically inject the necessary API key for gemini-2.0-flash. If you were running this outside of Canvas and needed a real API key, you would replace "" with your actual API key (though this is not recommended for client-side code in a production environment).

📺 Channel: DataWiz Vamshi
👍 Like • 💬 Comment your questions • 🔔 Subscribe for more AI + Python projects!

If you have any questions, please comment.

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post