Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,19 +49,24 @@ def check_password():
|
|
| 49 |
if not check_password():
|
| 50 |
st.stop() # Do not continue if check_password is not True.
|
| 51 |
|
| 52 |
-
def generate_zip(
|
| 53 |
"""Generates a zip file containing the input files."""
|
| 54 |
zip_buffer = io.BytesIO()
|
| 55 |
with zipfile.ZipFile(zip_buffer, 'w') as zip_file:
|
| 56 |
-
for
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
| 60 |
zip_buffer.seek(0)
|
| 61 |
return zip_buffer
|
| 62 |
|
|
|
|
|
|
|
| 63 |
text_input = st.text_area("Enter your software development requirements here:",
|
| 64 |
-
height=
|
| 65 |
value="""The goal.
|
| 66 |
|
| 67 |
The instructions of the task for each file example, things to do with input and output.
|
|
@@ -123,7 +128,8 @@ comments from Nick/Marc/...
|
|
| 123 |
""")
|
| 124 |
|
| 125 |
if st.button("Generate Code"):
|
| 126 |
-
st.
|
|
|
|
| 127 |
def download_content(url):
|
| 128 |
response = requests.get(url)
|
| 129 |
response.raise_for_status()
|
|
@@ -139,10 +145,12 @@ if st.button("Generate Code"):
|
|
| 139 |
except requests.exceptions.RequestException as e:
|
| 140 |
print(f"Error downloading content from {line}: {e}")
|
| 141 |
return '\n'.join(lines)
|
|
|
|
|
|
|
| 142 |
|
| 143 |
text_input = replace_urls_with_content(text_input)
|
| 144 |
repo: ProjectRepo = generate_repo(text_input)
|
| 145 |
-
zip_buffer = generate_zip(repo.
|
| 146 |
st.download_button(
|
| 147 |
label="Download Code Repository",
|
| 148 |
data=zip_buffer,
|
|
|
|
| 49 |
if not check_password():
|
| 50 |
st.stop() # Do not continue if check_password is not True.
|
| 51 |
|
| 52 |
+
def generate_zip(dir_path):
|
| 53 |
"""Generates a zip file containing the input files."""
|
| 54 |
zip_buffer = io.BytesIO()
|
| 55 |
with zipfile.ZipFile(zip_buffer, 'w') as zip_file:
|
| 56 |
+
for root, _, files in os.walk(dir_path):
|
| 57 |
+
# Add each file to the zip archive
|
| 58 |
+
for file in files:
|
| 59 |
+
file_path = os.path.join(root, file)
|
| 60 |
+
with open(file_path, 'rb') as f:
|
| 61 |
+
file_content = f.read()
|
| 62 |
+
zip_file.writestr(filename, file_content, arcname=os.path.relpath(file_path, dir_path))
|
| 63 |
zip_buffer.seek(0)
|
| 64 |
return zip_buffer
|
| 65 |
|
| 66 |
+
if "default" not in st.session_state:
|
| 67 |
+
st.session_state["default"] = 2000
|
| 68 |
text_input = st.text_area("Enter your software development requirements here:",
|
| 69 |
+
height=st.session_state["default"],
|
| 70 |
value="""The goal.
|
| 71 |
|
| 72 |
The instructions of the task for each file example, things to do with input and output.
|
|
|
|
| 128 |
""")
|
| 129 |
|
| 130 |
if st.button("Generate Code"):
|
| 131 |
+
st.balloons()
|
| 132 |
+
st.session_state["default"] = 200
|
| 133 |
def download_content(url):
|
| 134 |
response = requests.get(url)
|
| 135 |
response.raise_for_status()
|
|
|
|
| 145 |
except requests.exceptions.RequestException as e:
|
| 146 |
print(f"Error downloading content from {line}: {e}")
|
| 147 |
return '\n'.join(lines)
|
| 148 |
+
|
| 149 |
+
st.info('Working on it.. A download button will show up below once work done.')
|
| 150 |
|
| 151 |
text_input = replace_urls_with_content(text_input)
|
| 152 |
repo: ProjectRepo = generate_repo(text_input)
|
| 153 |
+
zip_buffer = generate_zip(repo.workdir())
|
| 154 |
st.download_button(
|
| 155 |
label="Download Code Repository",
|
| 156 |
data=zip_buffer,
|