Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,10 @@ import threading
|
|
14 |
from huggingface_hub import HfApi
|
15 |
from flask import send_file
|
16 |
|
|
|
|
|
|
|
|
|
17 |
# Configure logging
|
18 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
19 |
logger = logging.getLogger(__name__)
|
@@ -264,17 +268,20 @@ app.layout = dbc.Container([
|
|
264 |
[State("git-provider", "value"),
|
265 |
State("repo-url", "value"),
|
266 |
State("guide-type", "value"),
|
267 |
-
State('exclude-folders', 'value')]
|
268 |
)
|
269 |
def update_output(n_clicks, git_provider, repo_url, guide_type, exclude_folders):
|
270 |
if n_clicks is None:
|
271 |
raise PreventUpdate
|
272 |
|
|
|
|
|
273 |
def generate_guide_thread():
|
274 |
-
|
275 |
guide_text, docx_path, md_path = generate_guide(git_provider, repo_url, guide_type, exclude_folders)
|
|
|
276 |
|
277 |
-
guide_text
|
278 |
thread = threading.Thread(target=generate_guide_thread)
|
279 |
thread.start()
|
280 |
thread.join()
|
@@ -287,7 +294,7 @@ def update_output(n_clicks, git_provider, repo_url, guide_type, exclude_folders)
|
|
287 |
prevent_initial_call=True,
|
288 |
)
|
289 |
def download_docx(n_clicks):
|
290 |
-
if n_clicks is None:
|
291 |
raise PreventUpdate
|
292 |
return dcc.send_file(docx_path, filename="generated_guide.docx")
|
293 |
|
@@ -297,7 +304,7 @@ def download_docx(n_clicks):
|
|
297 |
prevent_initial_call=True,
|
298 |
)
|
299 |
def download_md(n_clicks):
|
300 |
-
if n_clicks is None:
|
301 |
raise PreventUpdate
|
302 |
return dcc.send_file(md_path, filename="generated_guide.md")
|
303 |
|
|
|
14 |
from huggingface_hub import HfApi
|
15 |
from flask import send_file
|
16 |
|
17 |
+
global docx_path, md_path
|
18 |
+
docx_path = None
|
19 |
+
md_path = None
|
20 |
+
|
21 |
# Configure logging
|
22 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
23 |
logger = logging.getLogger(__name__)
|
|
|
268 |
[State("git-provider", "value"),
|
269 |
State("repo-url", "value"),
|
270 |
State("guide-type", "value"),
|
271 |
+
State('exclude-folders', 'value')]
|
272 |
)
|
273 |
def update_output(n_clicks, git_provider, repo_url, guide_type, exclude_folders):
|
274 |
if n_clicks is None:
|
275 |
raise PreventUpdate
|
276 |
|
277 |
+
global docx_path, md_path
|
278 |
+
|
279 |
def generate_guide_thread():
|
280 |
+
global docx_path, md_path
|
281 |
guide_text, docx_path, md_path = generate_guide(git_provider, repo_url, guide_type, exclude_folders)
|
282 |
+
return guide_text
|
283 |
|
284 |
+
guide_text = None
|
285 |
thread = threading.Thread(target=generate_guide_thread)
|
286 |
thread.start()
|
287 |
thread.join()
|
|
|
294 |
prevent_initial_call=True,
|
295 |
)
|
296 |
def download_docx(n_clicks):
|
297 |
+
if n_clicks is None or docx_path is None:
|
298 |
raise PreventUpdate
|
299 |
return dcc.send_file(docx_path, filename="generated_guide.docx")
|
300 |
|
|
|
304 |
prevent_initial_call=True,
|
305 |
)
|
306 |
def download_md(n_clicks):
|
307 |
+
if n_clicks is None or md_path is None:
|
308 |
raise PreventUpdate
|
309 |
return dcc.send_file(md_path, filename="generated_guide.md")
|
310 |
|