awacke1 commited on
Commit
2475edf
·
verified ·
1 Parent(s): bdf693a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+ import streamlit.components.v1 as components
4
+ import os # Used to construct the file path reliably
5
+
6
+ # --- 1. Set Page Configuration ---
7
+ # This must be the first Streamlit command called
8
+ st.set_page_config(
9
+ page_title="Three.js Game Viewer",
10
+ layout="wide" # Set the layout to wide mode
11
+ )
12
+
13
+ st.header("🎮 Basic Three.js Game Embed")
14
+ st.caption("Displays the content of index.html below.")
15
+
16
+ # --- 2. Define the path to your HTML file ---
17
+ # Assumes index.html is in the same directory as app.py
18
+ html_file_path = 'index.html'
19
+
20
+ # --- 3. Read the HTML file ---
21
+ try:
22
+ with open(html_file_path, 'r', encoding='utf-8') as f:
23
+ html_content = f.read()
24
+
25
+ # --- 4. Embed the HTML into the Streamlit app ---
26
+ # Adjust the height as needed for your specific game view
27
+ components.html(
28
+ html_content,
29
+ height=700, # You might need to adjust this value
30
+ scrolling=False # Set to True if your HTML content needs scrolling
31
+ )
32
+
33
+ st.sidebar.info("Use WASD or Arrow Keys inside the frame above to move the cube.")
34
+
35
+ except FileNotFoundError:
36
+ st.error(f"Error: Could not find the file '{html_file_path}'.")
37
+ st.warning("Please make sure