Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,13 @@ import streamlit.components.v1 as components
|
|
3 |
import random
|
4 |
import string
|
5 |
import time
|
|
|
6 |
|
7 |
# Load the initial HTML5 app
|
|
|
|
|
|
|
|
|
8 |
with open("aframe_app.html", "r") as f:
|
9 |
initial_html = f.read()
|
10 |
|
@@ -26,7 +31,7 @@ def add_player():
|
|
26 |
while player_name in st.session_state.player_names:
|
27 |
player_name = generate_player_name()
|
28 |
st.session_state.player_names.append(player_name)
|
29 |
-
player_html = f'<a-entity id="{player_name}" geometry="primitive: box" material="color: {random.choice([
|
30 |
st.session_state.html_content = st.session_state.html_content.replace("</a-scene>", player_html + "\n</a-scene>")
|
31 |
|
32 |
# Streamlit app
|
|
|
3 |
import random
|
4 |
import string
|
5 |
import time
|
6 |
+
import os
|
7 |
|
8 |
# Load the initial HTML5 app
|
9 |
+
if not os.path.exists("aframe_app.html"):
|
10 |
+
with open("aframe_app.html", "w") as f:
|
11 |
+
f.write("<a-scene></a-scene>")
|
12 |
+
|
13 |
with open("aframe_app.html", "r") as f:
|
14 |
initial_html = f.read()
|
15 |
|
|
|
31 |
while player_name in st.session_state.player_names:
|
32 |
player_name = generate_player_name()
|
33 |
st.session_state.player_names.append(player_name)
|
34 |
+
player_html = f'<a-entity id="{player_name}" geometry="primitive: box" material="color: {random.choice(["red", "green", "blue", "yellow", "purple"])};"></a-entity>'
|
35 |
st.session_state.html_content = st.session_state.html_content.replace("</a-scene>", player_html + "\n</a-scene>")
|
36 |
|
37 |
# Streamlit app
|