Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def greet_and_recommend(name):
|
4 |
+
greeting = f"Hello {name}!!"
|
5 |
+
recommendations = ""
|
6 |
+
|
7 |
+
if "books" in name.lower():
|
8 |
+
recommendations += "\nSince you love books, here are some top recommendations:\n1. 'To Kill a Mockingbird' by Harper Lee\n2. '1984' by George Orwell\n3. 'The Great Gatsby' by F. Scott Fitzgerald\n4. 'Pride and Prejudice' by Jane Austen\n5. 'The Catcher in the Rye' by J.D. Salinger"
|
9 |
+
|
10 |
+
if "plays" in name.lower():
|
11 |
+
recommendations += "\n\nSince you love plays, here are some top recommendations:\n1. 'Hamlet' by William Shakespeare\n2. 'Death of a Salesman' by Arthur Miller\n3. 'A Streetcar Named Desire' by Tennessee Williams\n4. 'Waiting for Godot' by Samuel Beckett\n5. 'The Crucible' by Arthur Miller"
|
12 |
+
|
13 |
+
if "songs" in name.lower():
|
14 |
+
recommendations += "\n\nSince you love songs, here are some top recommendations:\n1. 'Bohemian Rhapsody' by Queen\n2. 'Imagine' by John Lennon\n3. 'Hotel California' by Eagles\n4. 'Stairway to Heaven' by Led Zeppelin\n5. 'Hey Jude' by The Beatles"
|
15 |
+
|
16 |
+
if not recommendations:
|
17 |
+
return greeting
|
18 |
+
else:
|
19 |
+
return greeting + "\n" + recommendations
|
20 |
+
|
21 |
+
demo = gr.Interface(fn=greet_and_recommend, inputs="text", outputs="text", title="Greet and Recommend", description="Enter your name, and if you love books, plays, or songs, you'll get recommendations!")
|
22 |
+
demo.launch()
|