time-teller / app.py
abdullahalioo's picture
Create app.py
8540d02 verified
raw
history blame
742 Bytes
# app.py
import gradio as gr
from datetime import datetime
import pytz
# Pakistan timezone
pakistan_tz = pytz.timezone("Asia/Karachi")
def chatbot(message):
message = message.lower()
if "time" in message:
now_pk = datetime.now(pakistan_tz)
return f"The current time in Pakistan is: {now_pk.strftime('%I:%M %p')}"
else:
return "I can only tell you the current time in Pakistan. Try asking: 'What is the time?'"
iface = gr.Interface(
fn=chatbot,
inputs=gr.Textbox(lines=2, placeholder="Ask me the time in Pakistan..."),
outputs="text",
title="Pakistan Time Bot",
description="A simple bot that tells you the current time in Pakistan."
)
if __name__ == "__main__":
iface.launch()