File size: 7,768 Bytes
93bff19
 
d8ff977
a857b87
 
c7715ea
d8ff977
 
 
f3a5264
d8ff977
 
 
f3a5264
d8ff977
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3a5264
d8ff977
 
 
 
 
 
 
 
f3a5264
d8ff977
 
 
 
 
 
 
 
 
 
 
f3a5264
d8ff977
 
 
 
 
 
 
 
 
 
 
f3a5264
d8ff977
 
 
 
f3a5264
40881d9
 
 
 
 
3e053da
 
 
 
 
 
 
 
40881d9
 
 
 
 
 
 
 
a857b87
 
 
 
 
 
40881d9
a857b87
 
40881d9
a857b87
40881d9
 
 
 
 
3e053da
 
 
 
 
 
 
 
 
 
a857b87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d21a64
 
f12ce5a
 
 
5d21a64
f12ce5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import streamlit as st
import os
import json
from PIL import Image


# Directory to store scores
score_dir = "scores"
os.makedirs(score_dir, exist_ok=True)

# Function to generate a unique key for each button
def generate_key(label, header, idx):
    return f"{header}_{label}_{idx}"

# Function to increment score and save it
def update_score(key, increment=1):
    score_file = os.path.join(score_dir, f"{key}.json")
    if os.path.exists(score_file):
        with open(score_file, "r") as file:
            score_data = json.load(file)
    else:
        score_data = {"clicks": 0, "score": 0}
    
    score_data["clicks"] += 1
    score_data["score"] += increment
    
    with open(score_file, "w") as file:
        json.dump(score_data, file)
    
    return score_data["score"]

# Function to load score
def load_score(key):
    score_file = os.path.join(score_dir, f"{key}.json")
    if os.path.exists(score_file):
        with open(score_file, "r") as file:
            score_data = json.load(file)
        return score_data["score"]
    return 0

# Display headers and buttons with scores
def display_buttons_with_scores():
    headers = ["Inputs", "Outputs", "Health", "Learning", "AI", "Writing"]
    buttons = [
        ["๐Ÿ“ Text", "๐Ÿ“– Read", "๐Ÿ“ท Photo", "๐Ÿ–ผ๏ธ View", "๐ŸŽ™๏ธ Record", "๐ŸŽง Listen", "๐ŸŽฅ Video", "๐Ÿ“น Capture"],
        ["๐Ÿ’ฌ Chat", "โœ๏ธ Write", "๐ŸŽจ Art", "๐ŸŒ„ Create", "๐ŸŽต Music", "๐ŸŽถ Compose", "๐Ÿ“ผ Watch", "๐Ÿฟ Movies"],
        ["๐Ÿ’‰ Vaccinate", "๐Ÿฉบ Diagnose", "๐Ÿฅ Hospital", "๐Ÿš‘ Emergency", "๐Ÿ’Š Meds", "๐Ÿฉน Bandage", "๐Ÿงฌ DNA", "๐Ÿ”ฌ Research", "๐ŸŒก๏ธ Temperature", "๐Ÿ Nutrition"],
        ["๐Ÿ“š Study", "๐Ÿง  Brain", "๐Ÿ‘ฉโ€๐ŸŽ“ Graduate", "๐Ÿ“ Measure", "๐Ÿ” Search", "๐Ÿ“Š Analyze", "๐Ÿ“‹ Plan", "๐Ÿ–‹๏ธ Write", "๐Ÿ‘จโ€๐Ÿซ Teach", "๐Ÿงฉ Puzzle"],
        ["๐Ÿค– Robot", "๐Ÿ‘พ Game", "๐Ÿ’ป Code", "๐Ÿงฎ Calculate", "๐Ÿ“ก Connect", "๐Ÿ”‹ Power", "๐Ÿ•น๏ธ Play", "๐Ÿ–ฅ๏ธ Display", "๐Ÿง‘โ€๐Ÿ’ป Develop", "๐Ÿ‘จโ€๐Ÿ”ฌ Experiment"],
        ["โœ๏ธ Author", "๐Ÿ“ Note", "๐Ÿ–Š๏ธ Pen", "๐Ÿ–‹๏ธ Sign", "๐Ÿ“š Library", "๐Ÿ”– Bookmark", "๐Ÿ““ Journal", "โœ’๏ธ Ink", "๐Ÿ“œ Scroll"]
    ]

    cols = st.columns(len(headers))
    for idx, (col, header, buttons_list) in enumerate(zip(cols, headers, buttons)):
        with col:
            st.markdown(f"### {header}")
            for button_idx, button_label in enumerate(buttons_list, start=1):
                key = generate_key(button_label, header, button_idx)
                score = load_score(key)
                if st.button(f"{button_label} {score}", key=key):
                    new_score = update_score(key)
                    # Reload the page to reflect the updated score
                    st.experimental_rerun()

# Main application logic
if __name__ == "__main__":
    st.markdown('# Remixable!')
    display_buttons_with_scores()

def fetch_wikipedia_summary(keyword):
    # Placeholder function for fetching Wikipedia summaries
    # In a real app, you might use requests to fetch from the Wikipedia API
    return f"Summary for {keyword}. For more information, visit Wikipedia."

def create_search_url_youtube(keyword):
    base_url = "https://www.youtube.com/results?search_query="
    return base_url + keyword.replace(' ', '+')

def create_search_url_bing(keyword):
    base_url = "https://www.bing.com/search?q="
    return base_url + keyword.replace(' ', '+')

def create_search_url_wikipedia(keyword):
    base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
    return base_url + keyword.replace(' ', '+')

def create_search_url_google(keyword):
    base_url = "https://www.google.com/search?q="
    return base_url + keyword.replace(' ', '+')

def display_images_and_wikipedia_summaries():
    st.title('Gallery with Related Stories')
    image_files = [f for f in os.listdir('.') if f.endswith('.png')]
    if not image_files:
        st.write("No PNG images found in the current directory.")
        return
    
    for image_file in image_files:
        image = Image.open(image_file)
        st.image(image, caption=image_file, use_column_width=True)
        
        keyword = image_file.split('.')[0]  # Assumes keyword is the file name without extension
        
        # Display Wikipedia and Google search links
        wikipedia_url = create_search_url_wikipedia(keyword)
        google_url = create_search_url_google(keyword)
        youtube_url = create_search_url_youtube(keyword)
        bing_url = create_search_url_bing(keyword)
        
        links_md = f"""
        [Wikipedia]({wikipedia_url}) | 
        [Google]({google_url}) | 
        [YouTube]({youtube_url}) | 
        [Bing]({bing_url})
        """
        st.markdown(links_md)

display_images_and_wikipedia_summaries()

st.markdown('# Three Dragons ๐Ÿ‰๐ŸŒ Mythical Dragons Around the World by Aaron Wacker')
dragons = {
    '#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.',
    '#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.',
    '#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.'
}
for dragon, story in dragons.items():
    st.subheader(dragon)
    st.markdown(f"- {story}")
st.markdown('''
https://github.com/AaronCWacker/ThreeDragons
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/vkNh6XnEtGSj8mXea1W6p.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/Kr_nqtaglHE_aiFxWH9zF.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/WLRKWqB6dKlMH6saVV9cX.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/Lyazf6FuX4nH__4illVki.png)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/ZemsxlT3b5idB0W5IjL1o.png)
''')

# Function to handle repeated query parameters
def get_all_query_params(key):
    return st.experimental_get_query_params().get(key, [])

# Function to clear all query parameters
def clear_query_params():
    st.experimental_set_query_params()  # Clear by setting to empty


st.title("Query Parameters Demo")

# Display current query parameters
st.write("Current Query Parameters:", st.experimental_get_query_params())

# Example: Using query parameters to navigate or trigger functionalities
if 'action' in st.experimental_get_query_params():
    action = st.experimental_get_query_params()['action'][0]  # Get the first (or only) 'action' parameter
    if action == 'show_message':
        st.success("Showing a message because 'action=show_message' was found in the URL.")
    elif action == 'clear':
        clear_query_params()
        st.experimental_rerun()

# Handling repeated keys
if 'multi' in st.experimental_get_query_params():
    multi_values = get_all_query_params('multi')
    st.write("Values for 'multi':", multi_values)

# Manual entry for demonstration
st.write("Enter query parameters in the URL like this: ?action=show_message&multi=1&multi=2")

# Clear query parameters button
if st.button("Clear Query Parameters"):
    clear_query_params()
    st.experimental_rerun()