awacke1's picture
Create app.py
2475edf verified
raw
history blame
1.21 kB
# app.py
import streamlit as st
import streamlit.components.v1 as components
import os # Used to construct the file path reliably
# --- 1. Set Page Configuration ---
# This must be the first Streamlit command called
st.set_page_config(
page_title="Three.js Game Viewer",
layout="wide" # Set the layout to wide mode
)
st.header("🎮 Basic Three.js Game Embed")
st.caption("Displays the content of index.html below.")
# --- 2. Define the path to your HTML file ---
# Assumes index.html is in the same directory as app.py
html_file_path = 'index.html'
# --- 3. Read the HTML file ---
try:
with open(html_file_path, 'r', encoding='utf-8') as f:
html_content = f.read()
# --- 4. Embed the HTML into the Streamlit app ---
# Adjust the height as needed for your specific game view
components.html(
html_content,
height=700, # You might need to adjust this value
scrolling=False # Set to True if your HTML content needs scrolling
)
st.sidebar.info("Use WASD or Arrow Keys inside the frame above to move the cube.")
except FileNotFoundError:
st.error(f"Error: Could not find the file '{html_file_path}'.")
st.warning("Please make sure