Update app.py
Browse files
app.py
CHANGED
|
@@ -135,14 +135,10 @@ def convert_endpoint():
|
|
| 135 |
include_fontawesome=data.get('include_fontawesome', False)
|
| 136 |
)
|
| 137 |
|
| 138 |
-
# Define options for wkhtmltoimage,
|
| 139 |
-
options = {
|
| 140 |
-
"quiet": "",
|
| 141 |
-
'encoding': "UTF-8",
|
| 142 |
-
'load-error-handling': 'ignore'
|
| 143 |
-
}
|
| 144 |
|
| 145 |
-
# Manually create and use a temporary file
|
| 146 |
temp_html_path = os.path.join(TEMP_DIR, f"{uuid.uuid4()}.html")
|
| 147 |
with open(temp_html_path, "w", encoding="utf-8") as f:
|
| 148 |
f.write(full_html)
|
|
@@ -165,7 +161,7 @@ def convert_endpoint():
|
|
| 165 |
traceback.print_exc()
|
| 166 |
return jsonify({'error': f'Failed to convert content: {str(e)}'}), 500
|
| 167 |
finally:
|
| 168 |
-
# Clean up the temporary file
|
| 169 |
if temp_html_path and os.path.exists(temp_html_path):
|
| 170 |
os.remove(temp_html_path)
|
| 171 |
|
|
|
|
| 135 |
include_fontawesome=data.get('include_fontawesome', False)
|
| 136 |
)
|
| 137 |
|
| 138 |
+
# Define options for wkhtmltoimage, removing the unsupported --no-cache
|
| 139 |
+
options = {"quiet": "", 'encoding': "UTF-8"}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
+
# --- REQUIRED CHANGE 2: Manually create and use a temporary file ---
|
| 142 |
temp_html_path = os.path.join(TEMP_DIR, f"{uuid.uuid4()}.html")
|
| 143 |
with open(temp_html_path, "w", encoding="utf-8") as f:
|
| 144 |
f.write(full_html)
|
|
|
|
| 161 |
traceback.print_exc()
|
| 162 |
return jsonify({'error': f'Failed to convert content: {str(e)}'}), 500
|
| 163 |
finally:
|
| 164 |
+
# --- REQUIRED CHANGE 3: Clean up the temporary file ---
|
| 165 |
if temp_html_path and os.path.exists(temp_html_path):
|
| 166 |
os.remove(temp_html_path)
|
| 167 |
|