update
Browse files1368 unmodified lines136913701371137213731374137527 unmodified lines14031404140514061407140814091410141114121413141414151416141714181419142014211422142314241368 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)27 unmodified linessrc_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# Escape the HTML content properly for the f-stringescaped_code = code.replace('"', '\\"').replace('\n', '\\n')streamlit_app_code = f'''import streamlit as stst.set_page_config(page_title="Generated App", layout="wide")# Display the HTML contenthtml_content = """{escaped_code}"""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"),1368 unmodified lines136913701371137213731374137527 unmodified lines140314041405140614071408140914101368 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)27 unmodified linessrc_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"),
app.py+2-16