Spaces:
Runtime error
Runtime error
Delete backup1.app.py
Browse files- backup1.app.py +0 -186
backup1.app.py
DELETED
@@ -1,186 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import os
|
3 |
-
import json
|
4 |
-
from PIL import Image
|
5 |
-
|
6 |
-
|
7 |
-
# Directory to store scores
|
8 |
-
score_dir = "scores"
|
9 |
-
os.makedirs(score_dir, exist_ok=True)
|
10 |
-
|
11 |
-
# Function to generate a unique key for each button
|
12 |
-
def generate_key(label, header, idx):
|
13 |
-
return f"{header}_{label}_{idx}"
|
14 |
-
|
15 |
-
# Function to increment score and save it
|
16 |
-
def update_score(key, increment=1):
|
17 |
-
score_file = os.path.join(score_dir, f"{key}.json")
|
18 |
-
if os.path.exists(score_file):
|
19 |
-
with open(score_file, "r") as file:
|
20 |
-
score_data = json.load(file)
|
21 |
-
else:
|
22 |
-
score_data = {"clicks": 0, "score": 0}
|
23 |
-
|
24 |
-
score_data["clicks"] += 1
|
25 |
-
score_data["score"] += increment
|
26 |
-
|
27 |
-
with open(score_file, "w") as file:
|
28 |
-
json.dump(score_data, file)
|
29 |
-
|
30 |
-
return score_data["score"]
|
31 |
-
|
32 |
-
# Function to load score
|
33 |
-
def load_score(key):
|
34 |
-
score_file = os.path.join(score_dir, f"{key}.json")
|
35 |
-
if os.path.exists(score_file):
|
36 |
-
with open(score_file, "r") as file:
|
37 |
-
score_data = json.load(file)
|
38 |
-
return score_data["score"]
|
39 |
-
return 0
|
40 |
-
|
41 |
-
# Display headers and buttons with scores
|
42 |
-
def display_buttons_with_scores():
|
43 |
-
headers = ["Inputs", "Outputs", "Health", "Learning", "AI", "Writing"]
|
44 |
-
buttons = [
|
45 |
-
["๐ Text", "๐ Read", "๐ท Photo", "๐ผ๏ธ View", "๐๏ธ Record", "๐ง Listen", "๐ฅ Video", "๐น Capture"],
|
46 |
-
["๐ฌ Chat", "โ๏ธ Write", "๐จ Art", "๐ Create", "๐ต Music", "๐ถ Compose", "๐ผ Watch", "๐ฟ Movies"],
|
47 |
-
["๐ Vaccinate", "๐ฉบ Diagnose", "๐ฅ Hospital", "๐ Emergency", "๐ Meds", "๐ฉน Bandage", "๐งฌ DNA", "๐ฌ Research", "๐ก๏ธ Temperature", "๐ Nutrition"],
|
48 |
-
["๐ Study", "๐ง Brain", "๐ฉโ๐ Graduate", "๐ Measure", "๐ Search", "๐ Analyze", "๐ Plan", "๐๏ธ Write", "๐จโ๐ซ Teach", "๐งฉ Puzzle"],
|
49 |
-
["๐ค Robot", "๐พ Game", "๐ป Code", "๐งฎ Calculate", "๐ก Connect", "๐ Power", "๐น๏ธ Play", "๐ฅ๏ธ Display", "๐งโ๐ป Develop", "๐จโ๐ฌ Experiment"],
|
50 |
-
["โ๏ธ Author", "๐ Note", "๐๏ธ Pen", "๐๏ธ Sign", "๐ Library", "๐ Bookmark", "๐ Journal", "โ๏ธ Ink", "๐ Scroll"]
|
51 |
-
]
|
52 |
-
|
53 |
-
cols = st.columns(len(headers))
|
54 |
-
for idx, (col, header, buttons_list) in enumerate(zip(cols, headers, buttons)):
|
55 |
-
with col:
|
56 |
-
st.markdown(f"### {header}")
|
57 |
-
for button_idx, button_label in enumerate(buttons_list, start=1):
|
58 |
-
key = generate_key(button_label, header, button_idx)
|
59 |
-
score = load_score(key)
|
60 |
-
if st.button(f"{button_label} {score}", key=key):
|
61 |
-
new_score = update_score(key)
|
62 |
-
# Reload the page to reflect the updated score
|
63 |
-
st.experimental_rerun()
|
64 |
-
|
65 |
-
# Main application logic
|
66 |
-
if __name__ == "__main__":
|
67 |
-
st.markdown('# Remixable!')
|
68 |
-
display_buttons_with_scores()
|
69 |
-
|
70 |
-
# Additional content and functionality can go here
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
col1, col2, col3 = st.columns(3)
|
78 |
-
|
79 |
-
with col1:
|
80 |
-
st.markdown('''### Inputs''')
|
81 |
-
st.button("๐ Text")
|
82 |
-
st.button("๐ Read")
|
83 |
-
st.button("๐ท Photo")
|
84 |
-
st.button("๐ผ๏ธ View")
|
85 |
-
st.button("๐๏ธ Record")
|
86 |
-
st.button("๐ง Listen")
|
87 |
-
st.button("๐ฅ Video")
|
88 |
-
st.button("๐น Capture")
|
89 |
-
|
90 |
-
with col2:
|
91 |
-
st.markdown('''### Outputs''')
|
92 |
-
st.button("๐ฌ Chat")
|
93 |
-
st.button("โ๏ธ Write")
|
94 |
-
st.button("๐จ Art")
|
95 |
-
st.button("๐ Create")
|
96 |
-
st.button("๐ต Music")
|
97 |
-
st.button("๐ถ Compose")
|
98 |
-
st.button("๐ผ Watch")
|
99 |
-
st.button("๐ฟ Movies")
|
100 |
-
|
101 |
-
with col3:
|
102 |
-
st.markdown('''### Health''')
|
103 |
-
st.button("๐ Vaccinate")
|
104 |
-
st.button("๐ฉบ Diagnose")
|
105 |
-
st.button("๐ฅ Hospital")
|
106 |
-
st.button("๐ Emergency")
|
107 |
-
st.button("๐ Meds")
|
108 |
-
st.button("๐ฉน Bandage")
|
109 |
-
st.button("๐งฌ DNA")
|
110 |
-
st.button("๐ฌ Research")
|
111 |
-
st.button("๐ก๏ธ Temperature")
|
112 |
-
st.button("๐ Nutrition")
|
113 |
-
|
114 |
-
col4, col5, col6 = st.columns(3)
|
115 |
-
|
116 |
-
with col4:
|
117 |
-
st.markdown('''### Learning''')
|
118 |
-
st.button("๐ Study")
|
119 |
-
st.button("๐ง Brain")
|
120 |
-
st.button("๐ฉโ๐ Graduate")
|
121 |
-
st.button("๐ Measure")
|
122 |
-
st.button("๐ Search")
|
123 |
-
st.button("๐ Analyze")
|
124 |
-
st.button("๐ Plan")
|
125 |
-
st.button("๐๏ธ Write")
|
126 |
-
st.button("๐จโ๐ซ Teach")
|
127 |
-
st.button("๐งฉ Puzzle")
|
128 |
-
|
129 |
-
with col5:
|
130 |
-
st.markdown('''### AI''')
|
131 |
-
st.button("๐ค Robot")
|
132 |
-
st.button("๐พ Game")
|
133 |
-
st.button("๐ป Code")
|
134 |
-
st.button("๐งฎ Calculate")
|
135 |
-
st.button("๐ก Connect")
|
136 |
-
st.button("๐ Power")
|
137 |
-
st.button("๐น๏ธ Play")
|
138 |
-
st.button("๐ฅ๏ธ Display")
|
139 |
-
st.button("๐งโ๐ป Develop")
|
140 |
-
st.button("๐จโ๐ฌ Experiment")
|
141 |
-
|
142 |
-
with col6:
|
143 |
-
st.markdown('''### Writing''')
|
144 |
-
st.button("โ๏ธ Author")
|
145 |
-
st.button("๐ Note")
|
146 |
-
st.button("๐๏ธ Pen")
|
147 |
-
st.button("๐๏ธ Sign")
|
148 |
-
st.button("๐ Library")
|
149 |
-
st.button("๐ Bookmark")
|
150 |
-
st.button("๐ Journal")
|
151 |
-
st.button("โ๏ธ Ink")
|
152 |
-
st.button("๐ Scroll")
|
153 |
-
|
154 |
-
def display_images_and_wikipedia_summaries():
|
155 |
-
st.title('Gallery with Related Stories')
|
156 |
-
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
157 |
-
if not image_files:
|
158 |
-
st.write("No PNG images found in the current directory.")
|
159 |
-
return
|
160 |
-
for image_file in image_files:
|
161 |
-
image = Image.open(image_file)
|
162 |
-
st.image(image, caption=image_file, use_column_width='always')
|
163 |
-
keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
|
164 |
-
|
165 |
-
wikipedia_summary = fetch_wikipedia_summary(keyword)
|
166 |
-
st.write(wikipedia_summary)
|
167 |
-
|
168 |
-
display_images_and_wikipedia_summaries()
|
169 |
-
|
170 |
-
st.markdown('# Three Dragons ๐๐ Mythical Dragons Around the World by Aaron Wacker')
|
171 |
-
dragons = {
|
172 |
-
'#Fafnir #Norse': '- **Story**: Fafnir originally a dwarf, transformed into a fierce dragon due to his greed for the treasure he guarded. He was later slain by the hero Sigurd. - **Significance**: deadly sin of greed and the corrupting power of wealth.',
|
173 |
-
'#Quetzalcoatl #Aztec': '- **Story**: Quetzalcoatl, the Feathered Serpent, is not a dragon in the traditional sense but shares many similarities. He was a deity representing wind, air, and learning. - **Significance**: creator god and a symbol of death and rebirth.',
|
174 |
-
'#Tiamat #Mesopotamian': '- **Story**: Tiamat, primordial goddess of ocean, turned into a dragon-like creature in a battle against her children who threatened her authority. - **Significance**: chaos of primordial creation and is often associated with the forces of nature.'
|
175 |
-
}
|
176 |
-
for dragon, story in dragons.items():
|
177 |
-
st.subheader(dragon)
|
178 |
-
st.markdown(f"- {story}")
|
179 |
-
st.markdown('''
|
180 |
-
https://github.com/AaronCWacker/ThreeDragons
|
181 |
-
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/vkNh6XnEtGSj8mXea1W6p.png)
|
182 |
-
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/Kr_nqtaglHE_aiFxWH9zF.png)
|
183 |
-
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/WLRKWqB6dKlMH6saVV9cX.png)
|
184 |
-
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/Lyazf6FuX4nH__4illVki.png)
|
185 |
-
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/ZemsxlT3b5idB0W5IjL1o.png)
|
186 |
-
''')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|