streamlit update
Browse files1368 unmodified lines136913701371137213731374137521 unmodified lines139713981399140014011402140314041405140614071408140914101368 unmodified lines# Create a temp dir for the structuretemp_dir = tempfile.mkdtemp()# 1. Write requirements.txtreqs = "altair\npandas\nstreamlit\n"req_path = os.path.join(temp_dir, "requirements.txt")with open(req_path, "w") as f:f.write(reqs)21 unmodified linesENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]'''dockerfile_path = os.path.join(temp_dir, "Dockerfile")with open(dockerfile_path, "w", newline="\n") as f:f.write(dockerfile_content)# 3. Write src/streamlit_app.pysrc_dir = os.path.join(temp_dir, "src")os.makedirs(src_dir, exist_ok=True)app_py_path = os.path.join(src_dir, "streamlit_app.py")with open(app_py_path, "w") as f:f.write(code)# Prepare files to uploadfiles_to_upload = [(req_path, "requirements.txt"),1368 unmodified lines136913701371137213731374137521 unmodified lines139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221368 unmodified lines# Create a temp dir for the structuretemp_dir = tempfile.mkdtemp()# 1. Write requirements.txtreqs = "streamlit>=1.28.0\n"req_path = os.path.join(temp_dir, "requirements.txt")with open(req_path, "w") as f:f.write(reqs)21 unmodified linesENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]'''dockerfile_path = os.path.join(temp_dir, "Dockerfile")with open(dockerfile_path, "w", encoding="utf-8", newline="\n") as f:f.write(dockerfile_content)# 3. Write src/streamlit_app.pysrc_dir = os.path.join(temp_dir, "src")os.makedirs(src_dir, exist_ok=True)app_py_path = os.path.join(src_dir, "streamlit_app.py")# Convert HTML code to Streamlit appstreamlit_app_code = f'''import streamlit as stst.set_page_config(page_title="Generated App", layout="wide")# Display the HTML contenthtml_content = """{code.replace('"""', '\\"""')}"""st.components.v1.html(html_content, height=800, scrolling=True)'''with open(app_py_path, "w") as f:f.write(streamlit_app_code)# Prepare files to uploadfiles_to_upload = [(req_path, "requirements.txt"),
app.py+15-3