Commit
·
0ecc614
1
Parent(s):
d421cc0
update
Browse files
app.py
CHANGED
@@ -136,18 +136,27 @@ def index():
|
|
136 |
return render_template('index.html')
|
137 |
|
138 |
|
|
|
|
|
|
|
|
|
139 |
def modify_plan_of_sqls_html(html_content):
|
140 |
soup = BeautifulSoup(html_content, 'html.parser')
|
141 |
|
142 |
-
# Remove the final table
|
143 |
-
final_table = soup.find('table',
|
144 |
if final_table:
|
145 |
final_table.decompose()
|
146 |
|
147 |
# Remove the Prediction line
|
148 |
-
|
149 |
-
if
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
return str(soup)
|
153 |
|
@@ -172,12 +181,12 @@ def experiment(username):
|
|
172 |
|
173 |
# Modify the HTML content for Plan-of-SQLs
|
174 |
if method == 'Plan-of-SQLs':
|
175 |
-
with open(visualization_path, 'r') as file:
|
176 |
html_content = file.read()
|
177 |
modified_html = modify_plan_of_sqls_html(html_content)
|
178 |
# Save the modified HTML to a temporary file
|
179 |
temp_path = f"/tmp/{sample['file']}"
|
180 |
-
with open(temp_path, 'w') as file:
|
181 |
file.write(modified_html)
|
182 |
visualization_path = temp_path
|
183 |
|
|
|
136 |
return render_template('index.html')
|
137 |
|
138 |
|
139 |
+
from bs4 import BeautifulSoup
|
140 |
+
import re
|
141 |
+
|
142 |
+
|
143 |
def modify_plan_of_sqls_html(html_content):
|
144 |
soup = BeautifulSoup(html_content, 'html.parser')
|
145 |
|
146 |
+
# Remove the final table (verification result)
|
147 |
+
final_table = soup.find('table', id=lambda x: x and x.startswith('step-'))
|
148 |
if final_table:
|
149 |
final_table.decompose()
|
150 |
|
151 |
# Remove the Prediction line
|
152 |
+
prediction_h3 = soup.find('h3', string=re.compile(r'Prediction:'))
|
153 |
+
if prediction_h3:
|
154 |
+
prediction_h3.decompose()
|
155 |
+
|
156 |
+
# Remove any extra <hr> tags at the end if present
|
157 |
+
last_hr = soup.find_all('hr')[-1]
|
158 |
+
if last_hr:
|
159 |
+
last_hr.decompose()
|
160 |
|
161 |
return str(soup)
|
162 |
|
|
|
181 |
|
182 |
# Modify the HTML content for Plan-of-SQLs
|
183 |
if method == 'Plan-of-SQLs':
|
184 |
+
with open(visualization_path, 'r', encoding='utf-8') as file:
|
185 |
html_content = file.read()
|
186 |
modified_html = modify_plan_of_sqls_html(html_content)
|
187 |
# Save the modified HTML to a temporary file
|
188 |
temp_path = f"/tmp/{sample['file']}"
|
189 |
+
with open(temp_path, 'w', encoding='utf-8') as file:
|
190 |
file.write(modified_html)
|
191 |
visualization_path = temp_path
|
192 |
|