Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,115 +1,68 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
st.button("๐ผ Watch")
|
| 31 |
-
st.button("๐ฟ Movies")
|
| 32 |
|
| 33 |
-
with
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
st.button("๐ Nutrition")
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
st.
|
| 51 |
-
|
| 52 |
-
st.button("๐ฉโ๐ Graduate")
|
| 53 |
-
st.button("๐ Measure")
|
| 54 |
-
st.button("๐ Search")
|
| 55 |
-
st.button("๐ Analyze")
|
| 56 |
-
st.button("๐ Plan")
|
| 57 |
-
st.button("๐๏ธ Write")
|
| 58 |
-
st.button("๐จโ๐ซ Teach")
|
| 59 |
-
st.button("๐งฉ Puzzle")
|
| 60 |
|
| 61 |
-
|
| 62 |
-
st.markdown('''### AI''')
|
| 63 |
-
st.button("๐ค Robot")
|
| 64 |
-
st.button("๐พ Game")
|
| 65 |
-
st.button("๐ป Code")
|
| 66 |
-
st.button("๐งฎ Calculate")
|
| 67 |
-
st.button("๐ก Connect")
|
| 68 |
-
st.button("๐ Power")
|
| 69 |
-
st.button("๐น๏ธ Play")
|
| 70 |
-
st.button("๐ฅ๏ธ Display")
|
| 71 |
-
st.button("๐งโ๐ป Develop")
|
| 72 |
-
st.button("๐จโ๐ฌ Experiment")
|
| 73 |
-
|
| 74 |
-
with col6:
|
| 75 |
-
st.markdown('''### Writing''')
|
| 76 |
-
st.button("โ๏ธ Author")
|
| 77 |
-
st.button("๐ Note")
|
| 78 |
-
st.button("๐๏ธ Pen")
|
| 79 |
-
st.button("๐๏ธ Sign")
|
| 80 |
-
st.button("๐ Library")
|
| 81 |
-
st.button("๐ Bookmark")
|
| 82 |
-
st.button("๐ Journal")
|
| 83 |
-
st.button("โ๏ธ Ink")
|
| 84 |
-
st.button("๐ Scroll")
|
| 85 |
-
|
| 86 |
-
def display_images_and_wikipedia_summaries():
|
| 87 |
-
st.title('Gallery with Related Stories')
|
| 88 |
-
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
| 89 |
-
if not image_files:
|
| 90 |
-
st.write("No PNG images found in the current directory.")
|
| 91 |
-
return
|
| 92 |
-
for image_file in image_files:
|
| 93 |
-
image = Image.open(image_file)
|
| 94 |
-
st.image(image, caption=image_file, use_column_width='always')
|
| 95 |
-
keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
|
| 96 |
-
|
| 97 |
-
display_images_and_wikipedia_summaries()
|
| 98 |
-
|
| 99 |
-
st.markdown('# Three Dragons ๐๐ Mythical Dragons Around the World by Aaron Wacker')
|
| 100 |
-
dragons = {
|
| 101 |
-
'#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.',
|
| 102 |
-
'#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.',
|
| 103 |
-
'#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.'
|
| 104 |
-
}
|
| 105 |
-
for dragon, story in dragons.items():
|
| 106 |
-
st.subheader(dragon)
|
| 107 |
-
st.markdown(f"- {story}")
|
| 108 |
-
st.markdown('''
|
| 109 |
-
https://github.com/AaronCWacker/ThreeDragons
|
| 110 |
-

|
| 111 |
-

|
| 112 |
-

|
| 113 |
-

|
| 114 |
-

|
| 115 |
-
''')
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
+
import json
|
| 4 |
|
| 5 |
+
# Directory to store scores
|
| 6 |
+
score_dir = "scores"
|
| 7 |
+
os.makedirs(score_dir, exist_ok=True)
|
| 8 |
|
| 9 |
+
# Function to generate a unique key for each button
|
| 10 |
+
def generate_key(label, header, idx):
|
| 11 |
+
return f"{header}_{label}_{idx}"
|
| 12 |
|
| 13 |
+
# Function to increment score and save it
|
| 14 |
+
def update_score(key, increment=1):
|
| 15 |
+
score_file = os.path.join(score_dir, f"{key}.json")
|
| 16 |
+
if os.path.exists(score_file):
|
| 17 |
+
with open(score_file, "r") as file:
|
| 18 |
+
score_data = json.load(file)
|
| 19 |
+
else:
|
| 20 |
+
score_data = {"clicks": 0, "score": 0}
|
| 21 |
+
|
| 22 |
+
score_data["clicks"] += 1
|
| 23 |
+
score_data["score"] += increment
|
| 24 |
+
|
| 25 |
+
with open(score_file, "w") as file:
|
| 26 |
+
json.dump(score_data, file)
|
| 27 |
+
|
| 28 |
+
return score_data["score"]
|
| 29 |
|
| 30 |
+
# Function to load score
|
| 31 |
+
def load_score(key):
|
| 32 |
+
score_file = os.path.join(score_dir, f"{key}.json")
|
| 33 |
+
if os.path.exists(score_file):
|
| 34 |
+
with open(score_file, "r") as file:
|
| 35 |
+
score_data = json.load(file)
|
| 36 |
+
return score_data["score"]
|
| 37 |
+
return 0
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
# Display headers and buttons with scores
|
| 40 |
+
def display_buttons_with_scores():
|
| 41 |
+
headers = ["Inputs", "Outputs", "Health", "Learning", "AI", "Writing"]
|
| 42 |
+
buttons = [
|
| 43 |
+
["๐ Text", "๐ Read", "๐ท Photo", "๐ผ๏ธ View", "๐๏ธ Record", "๐ง Listen", "๐ฅ Video", "๐น Capture"],
|
| 44 |
+
["๐ฌ Chat", "โ๏ธ Write", "๐จ Art", "๐ Create", "๐ต Music", "๐ถ Compose", "๐ผ Watch", "๐ฟ Movies"],
|
| 45 |
+
["๐ Vaccinate", "๐ฉบ Diagnose", "๐ฅ Hospital", "๐ Emergency", "๐ Meds", "๐ฉน Bandage", "๐งฌ DNA", "๐ฌ Research", "๐ก๏ธ Temperature", "๐ Nutrition"],
|
| 46 |
+
["๐ Study", "๐ง Brain", "๐ฉโ๐ Graduate", "๐ Measure", "๐ Search", "๐ Analyze", "๐ Plan", "๐๏ธ Write", "๐จโ๐ซ Teach", "๐งฉ Puzzle"],
|
| 47 |
+
["๐ค Robot", "๐พ Game", "๐ป Code", "๐งฎ Calculate", "๐ก Connect", "๐ Power", "๐น๏ธ Play", "๐ฅ๏ธ Display", "๐งโ๐ป Develop", "๐จโ๐ฌ Experiment"],
|
| 48 |
+
["โ๏ธ Author", "๐ Note", "๐๏ธ Pen", "๐๏ธ Sign", "๐ Library", "๐ Bookmark", "๐ Journal", "โ๏ธ Ink", "๐ Scroll"]
|
| 49 |
+
]
|
|
|
|
| 50 |
|
| 51 |
+
cols = st.columns(len(headers))
|
| 52 |
+
for idx, (col, header, buttons_list) in enumerate(zip(cols, headers, buttons)):
|
| 53 |
+
with col:
|
| 54 |
+
st.markdown(f"### {header}")
|
| 55 |
+
for button_idx, button_label in enumerate(buttons_list, start=1):
|
| 56 |
+
key = generate_key(button_label, header, button_idx)
|
| 57 |
+
score = load_score(key)
|
| 58 |
+
if st.button(f"{button_label} {score}", key=key):
|
| 59 |
+
new_score = update_score(key)
|
| 60 |
+
# Reload the page to reflect the updated score
|
| 61 |
+
st.experimental_rerun()
|
| 62 |
|
| 63 |
+
# Main application logic
|
| 64 |
+
if __name__ == "__main__":
|
| 65 |
+
st.markdown('# Remixable!')
|
| 66 |
+
display_buttons_with_scores()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
# Additional content and functionality can go here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|