Spaces:
Running
Running
streamlit update
Browse files
app.py
CHANGED
@@ -1369,7 +1369,7 @@ with gr.Blocks(
|
|
1369 |
# Create a temp dir for the structure
|
1370 |
temp_dir = tempfile.mkdtemp()
|
1371 |
# 1. Write requirements.txt
|
1372 |
-
reqs = "
|
1373 |
req_path = os.path.join(temp_dir, "requirements.txt")
|
1374 |
with open(req_path, "w") as f:
|
1375 |
f.write(reqs)
|
@@ -1397,14 +1397,26 @@ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
|
1397 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
1398 |
'''
|
1399 |
dockerfile_path = os.path.join(temp_dir, "Dockerfile")
|
1400 |
-
with open(dockerfile_path, "w", newline="\n") as f:
|
1401 |
f.write(dockerfile_content)
|
1402 |
# 3. Write src/streamlit_app.py
|
1403 |
src_dir = os.path.join(temp_dir, "src")
|
1404 |
os.makedirs(src_dir, exist_ok=True)
|
1405 |
app_py_path = os.path.join(src_dir, "streamlit_app.py")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1406 |
with open(app_py_path, "w") as f:
|
1407 |
-
f.write(
|
1408 |
# Prepare files to upload
|
1409 |
files_to_upload = [
|
1410 |
(req_path, "requirements.txt"),
|
|
|
1369 |
# Create a temp dir for the structure
|
1370 |
temp_dir = tempfile.mkdtemp()
|
1371 |
# 1. Write requirements.txt
|
1372 |
+
reqs = "streamlit>=1.28.0\n"
|
1373 |
req_path = os.path.join(temp_dir, "requirements.txt")
|
1374 |
with open(req_path, "w") as f:
|
1375 |
f.write(reqs)
|
|
|
1397 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
1398 |
'''
|
1399 |
dockerfile_path = os.path.join(temp_dir, "Dockerfile")
|
1400 |
+
with open(dockerfile_path, "w", encoding="utf-8", newline="\n") as f:
|
1401 |
f.write(dockerfile_content)
|
1402 |
# 3. Write src/streamlit_app.py
|
1403 |
src_dir = os.path.join(temp_dir, "src")
|
1404 |
os.makedirs(src_dir, exist_ok=True)
|
1405 |
app_py_path = os.path.join(src_dir, "streamlit_app.py")
|
1406 |
+
|
1407 |
+
# Convert HTML code to Streamlit app
|
1408 |
+
streamlit_app_code = f'''import streamlit as st
|
1409 |
+
|
1410 |
+
st.set_page_config(page_title="Generated App", layout="wide")
|
1411 |
+
|
1412 |
+
# Display the HTML content
|
1413 |
+
html_content = """{code.replace('"""', '\\"""')}"""
|
1414 |
+
|
1415 |
+
st.components.v1.html(html_content, height=800, scrolling=True)
|
1416 |
+
'''
|
1417 |
+
|
1418 |
with open(app_py_path, "w") as f:
|
1419 |
+
f.write(streamlit_app_code)
|
1420 |
# Prepare files to upload
|
1421 |
files_to_upload = [
|
1422 |
(req_path, "requirements.txt"),
|