Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -173,15 +173,29 @@ with gr.Blocks(title="Категоризатор сайтов", theme=gr.themes.
|
|
173 |
|
174 |
csv_data = gr.State("")
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
def handle_connect(url):
|
177 |
status, iframe_url = app.connect_to_sheet(url)
|
178 |
if "✅" in status:
|
179 |
url_display, category, info = app.get_current_info()
|
|
|
|
|
|
|
|
|
180 |
iframe_html = f'<iframe src="{iframe_url}" width="100%" height="900px" style="border-radius:8px;"></iframe>'
|
181 |
-
return status, iframe_html, url_display, category, info
|
182 |
else:
|
183 |
-
return status, website_viewer.value, "",
|
184 |
|
|
|
185 |
def handle_navigation(direction):
|
186 |
if direction == "next":
|
187 |
url_display, category, info, iframe_url = app.next_record()
|
|
|
173 |
|
174 |
csv_data = gr.State("")
|
175 |
|
176 |
+
# def handle_connect(url):
|
177 |
+
# status, iframe_url = app.connect_to_sheet(url)
|
178 |
+
# if "✅" in status:
|
179 |
+
# url_display, category, info = app.get_current_info()
|
180 |
+
# iframe_html = f'<iframe src="{iframe_url}" width="100%" height="900px" style="border-radius:8px;"></iframe>'
|
181 |
+
# return status, iframe_html, url_display, category, info
|
182 |
+
# else:
|
183 |
+
# return status, website_viewer.value, "", "", ""
|
184 |
+
|
185 |
def handle_connect(url):
|
186 |
status, iframe_url = app.connect_to_sheet(url)
|
187 |
if "✅" in status:
|
188 |
url_display, category, info = app.get_current_info()
|
189 |
+
|
190 |
+
# dynamically merge categories from data
|
191 |
+
all_categories = list(set(app.categories + [c for c in (row["category"] for row in app.results_data) if c]))
|
192 |
+
|
193 |
iframe_html = f'<iframe src="{iframe_url}" width="100%" height="900px" style="border-radius:8px;"></iframe>'
|
194 |
+
return status, iframe_html, url_display, gr.Dropdown.update(choices=all_categories, value=category), info
|
195 |
else:
|
196 |
+
return status, website_viewer.value, "", gr.Dropdown.update(choices=app.categories, value=None), ""
|
197 |
|
198 |
+
|
199 |
def handle_navigation(direction):
|
200 |
if direction == "next":
|
201 |
url_display, category, info, iframe_url = app.next_record()
|