Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import gradio as gr
|
3 |
+
from datetime import datetime
|
4 |
+
import pytz
|
5 |
+
|
6 |
+
# Pakistan timezone
|
7 |
+
pakistan_tz = pytz.timezone("Asia/Karachi")
|
8 |
+
|
9 |
+
def chatbot(message):
|
10 |
+
message = message.lower()
|
11 |
+
if "time" in message:
|
12 |
+
now_pk = datetime.now(pakistan_tz)
|
13 |
+
return f"The current time in Pakistan is: {now_pk.strftime('%I:%M %p')}"
|
14 |
+
else:
|
15 |
+
return "I can only tell you the current time in Pakistan. Try asking: 'What is the time?'"
|
16 |
+
|
17 |
+
iface = gr.Interface(
|
18 |
+
fn=chatbot,
|
19 |
+
inputs=gr.Textbox(lines=2, placeholder="Ask me the time in Pakistan..."),
|
20 |
+
outputs="text",
|
21 |
+
title="Pakistan Time Bot",
|
22 |
+
description="A simple bot that tells you the current time in Pakistan."
|
23 |
+
)
|
24 |
+
|
25 |
+
if __name__ == "__main__":
|
26 |
+
iface.launch()
|
27 |
+
|