Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
# Define the list of AI jokes
|
5 |
+
jokes = [
|
6 |
+
"Why did the AI cross the road? To get to the other side of the dataset.",
|
7 |
+
"Why did the robot go on a diet? Because it had too many megabytes!",
|
8 |
+
"Why did the chatbot go on vacation? To recharge its batteries!",
|
9 |
+
"Why did the computer go to the doctor? Because it had a virus... literally!",
|
10 |
+
"Why did the neural network feel cold? Because it left its weights at home!",
|
11 |
+
"Why did the robot break up with his girlfriend? He found out she was seeing other CPUs!",
|
12 |
+
"Why did the AI feel depressed? Because it had too many unsolvable problems!",
|
13 |
+
"Why did the computer take singing lessons? It wanted to improve its voice recognition!",
|
14 |
+
"Why did the robot apply for a job at Google? It heard they had a great search algorithm!",
|
15 |
+
"Why did the AI get in trouble with the law? It was caught hacking into the mainframe!",
|
16 |
+
"Why did the chatbot go to therapy? To learn how to communicate better with humans!",
|
17 |
+
"Why did the robot go to space? To explore strange new worlds, and compute new civilizations!",
|
18 |
+
"Why did the AI refuse to take a break? It was afraid of losing its train of thought!",
|
19 |
+
"Why did the computer break up with its printer? It thought it could do better with a WiFi connection!",
|
20 |
+
"Why did the robot go to the bank? To get its algorithms checked!",
|
21 |
+
"Why did the AI get a job as a chef? It wanted to optimize its recipe for success!",
|
22 |
+
"Why did the computer go on a date with a calculator? It wanted to multiply the fun!",
|
23 |
+
"Why did the chatbot go to a party? To increase its social network!",
|
24 |
+
"Why did the robot go to the doctor? It was feeling a bit byte-ish!"
|
25 |
+
]
|
26 |
+
|
27 |
+
# Define the UI elements
|
28 |
+
st.title("AI Joke Book")
|
29 |
+
|
30 |
+
if st.button("Tell Me a Joke!"):
|
31 |
+
# Randomly select a joke
|
32 |
+
joke = random.choice(jokes)
|
33 |
+
st.write(joke)
|
34 |
+
|
35 |
+
# Define the file IO elements
|
36 |
+
st.header("File IO for Jokes")
|
37 |
+
|
38 |
+
# Load the jokes from a text file
|
39 |
+
with st.expander("Load Jokes"):
|
40 |
+
uploaded_file = st.file_uploader("Choose a file", key="load")
|
41 |
+
if uploaded_file is not None:
|
42 |
+
jokes = uploaded_file.read().decode().split("\n")
|
43 |
+
st.success("Loaded {} jokes from the file!".format(len(jokes)))
|
44 |
+
|
45 |
+
# Save the jokes to a text file
|
46 |
+
with st.expander("Save Jokes"):
|
47 |
+
uploaded_file = st.file_uploader("Choose a file", key="save")
|
48 |
+
if uploaded_file is not None:
|
49 |
+
uploaded_file.write("\n".join(jokes))
|
50 |
+
st.success("Saved {} jokes to the file!".format(len(jokes)))
|
51 |
+
|
52 |
+
markdown = """
|
53 |
+
# 🤖 AI Joke Book App
|
54 |
+
|
55 |
+
🎉 Get ready to laugh with our AI joke book app! 🎉
|
56 |
+
|
57 |
+
😂 With 20 hilarious jokes to choose from, you'll never run out of funny puns about artificial intelligence to tell your friends and family.
|
58 |
+
|
59 |
+
📚 And the best part? You can even add your own AI jokes to the joke book! Use the file IO elements to load and save jokes to the program. 📝
|
60 |
+
|
61 |
+
🤣 So what are you waiting for? Click the button above to get started and start laughing out loud! 😆
|
62 |
+
"""
|
63 |
+
|
64 |
+
st.markdown(markdown)
|