Spaces:
Build error
Build error
Sanket Kathrotiya commited on
Commit ·
f89e163
1
Parent(s): 2332b04
v0
Browse files- app.py +13 -10
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -1,18 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
import datetime
|
| 4 |
|
| 5 |
-
def is_weekday(date: datetime
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
|
|
|
| 8 |
demo = gr.Interface(
|
| 9 |
-
fn=is_weekday,
|
| 10 |
-
inputs=
|
| 11 |
-
outputs=gr.
|
| 12 |
-
examples=[
|
| 13 |
-
|
| 14 |
-
title="Is it a weekday?"
|
| 15 |
)
|
| 16 |
|
|
|
|
| 17 |
if __name__ == "__main__":
|
| 18 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from datetime import datetime
|
|
|
|
| 3 |
|
| 4 |
+
def is_weekday(date: datetime):
|
| 5 |
+
# Check if the selected date is a weekday (Monday to Friday)
|
| 6 |
+
if isinstance(date, str):
|
| 7 |
+
date = datetime.fromisoformat(date)
|
| 8 |
+
return "Yes, it's a weekday." if date.weekday() < 5 else "No, it's a weekend."
|
| 9 |
|
| 10 |
+
# Create the Gradio interface with the DateTime component
|
| 11 |
demo = gr.Interface(
|
| 12 |
+
fn=is_weekday, # Function to check if the selected date is a weekday
|
| 13 |
+
inputs=gr.DateTime(label="Select a date and time", type="datetime", include_time=True),
|
| 14 |
+
outputs=gr.Textbox(label="Is it a weekday?"),
|
| 15 |
+
examples=["2024-08-29 14:00:00", "2024-08-30 09:30:00"], # Example dates for users to try
|
| 16 |
+
title="Weekday Checker"
|
|
|
|
| 17 |
)
|
| 18 |
|
| 19 |
+
# Launch the Gradio interface
|
| 20 |
if __name__ == "__main__":
|
| 21 |
demo.launch()
|
requirements.txt
CHANGED
|
@@ -2,4 +2,4 @@ numpy==1.26.4
|
|
| 2 |
pandas==2.2.2
|
| 3 |
xgboost==2.1.1
|
| 4 |
gradio
|
| 5 |
-
|
|
|
|
| 2 |
pandas==2.2.2
|
| 3 |
xgboost==2.1.1
|
| 4 |
gradio
|
| 5 |
+
|