Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,41 @@ from PIL import Image
|
|
6 |
# Set page configuration
|
7 |
st.set_page_config(page_title="🌌🚀 Remixable AI for Sci-Fi and Fantasy Storytelling", page_icon="🪐", layout="wide")
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Transhuman Space glossary
|
10 |
transhuman_glossary = {
|
11 |
"🚀 Core Technologies": ["Nanotechnology", "Artificial Intelligence", "Quantum Computing", "Spacecraft Engineering", "Biotechnology", "Cybernetics", "Virtual Reality", "Energy Systems", "Material Science", "Communication Technologies"],
|
|
|
6 |
# Set page configuration
|
7 |
st.set_page_config(page_title="🌌🚀 Remixable AI for Sci-Fi and Fantasy Storytelling", page_icon="🪐", layout="wide")
|
8 |
|
9 |
+
# Directory to store scores
|
10 |
+
score_dir = "scores"
|
11 |
+
os.makedirs(score_dir, exist_ok=True)
|
12 |
+
|
13 |
+
# Function to generate a unique key for each button
|
14 |
+
def generate_key(label, header, idx):
|
15 |
+
# Creates a unique key by combining label, header, and index
|
16 |
+
return f"{header}_{label}_{idx}"
|
17 |
+
|
18 |
+
# Function to increment score and save it
|
19 |
+
def update_score(key, increment=1):
|
20 |
+
score_file = os.path.join(score_dir, f"{key}.json")
|
21 |
+
if os.path.exists(score_file):
|
22 |
+
with open(score_file, "r") as file:
|
23 |
+
score_data = json.load(file)
|
24 |
+
else:
|
25 |
+
score_data = {"clicks": 0, "score": 0}
|
26 |
+
|
27 |
+
score_data["clicks"] += 1
|
28 |
+
score_data["score"] += increment
|
29 |
+
|
30 |
+
with open(score_file, "w") as file:
|
31 |
+
json.dump(score_data, file)
|
32 |
+
|
33 |
+
return score_data["score"]
|
34 |
+
|
35 |
+
# Function to load score
|
36 |
+
def load_score(key):
|
37 |
+
score_file = os.path.join(score_dir, f"{key}.json")
|
38 |
+
if os.path.exists(score_file):
|
39 |
+
with open(score_file, "r") as file:
|
40 |
+
score_data = json.load(file)
|
41 |
+
return score_data["score"]
|
42 |
+
return 0
|
43 |
+
|
44 |
# Transhuman Space glossary
|
45 |
transhuman_glossary = {
|
46 |
"🚀 Core Technologies": ["Nanotechnology", "Artificial Intelligence", "Quantum Computing", "Spacecraft Engineering", "Biotechnology", "Cybernetics", "Virtual Reality", "Energy Systems", "Material Science", "Communication Technologies"],
|