streamlit update
Browse files1368 unmodified lines1369137013711372137213731374137521 unmodified lines13971398139914001400140114021403140414051406140714081409141014111412141314141415141614171418140714191420142114221368 unmodified lines # Create a temp dir for the structure temp_dir = tempfile.mkdtemp() # 1. Write requirements.txt reqs = "altair\npandas\nstreamlit\n" reqs = "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", newline="\n") as f: with open(dockerfile_path, "w", encoding="utf-8", newline="\n") as f: f.write(dockerfile_content) # 3. Write src/streamlit_app.py src_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 app streamlit_app_code = f'''import streamlit as st
st.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(code) f.write(streamlit_app_code) # Prepare files to upload files_to_upload = [ (req_path, "requirements.txt"),app.py+15-3