Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -439,8 +439,7 @@ def show_details_html(choice, previous_output, initial_state):
|
|
| 439 |
|
| 440 |
|
| 441 |
def get_pwa_html():
|
| 442 |
-
|
| 443 |
-
manifest_content = {
|
| 444 |
"name": "PawMatch AI",
|
| 445 |
"short_name": "PawMatch",
|
| 446 |
"start_url": ".",
|
|
@@ -454,7 +453,7 @@ def get_pwa_html():
|
|
| 454 |
"type": "image/png"
|
| 455 |
}
|
| 456 |
]
|
| 457 |
-
}
|
| 458 |
|
| 459 |
return f"""
|
| 460 |
<!DOCTYPE html>
|
|
@@ -463,47 +462,60 @@ def get_pwa_html():
|
|
| 463 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
| 464 |
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
| 465 |
<meta name="theme-color" content="#4299e1">
|
|
|
|
| 466 |
|
| 467 |
<script type="application/json" id="pwa-manifest">
|
| 468 |
-
{
|
| 469 |
</script>
|
| 470 |
|
| 471 |
<script>
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
</script>
|
| 496 |
|
| 497 |
<style>
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
|
|
|
|
|
|
|
|
|
| 501 |
}}
|
| 502 |
|
| 503 |
-
@
|
| 504 |
body {{
|
| 505 |
-
padding-top:
|
| 506 |
-
padding-bottom:
|
| 507 |
}}
|
| 508 |
}}
|
| 509 |
</style>
|
|
|
|
| 439 |
|
| 440 |
|
| 441 |
def get_pwa_html():
|
| 442 |
+
manifest_content = '''{
|
|
|
|
| 443 |
"name": "PawMatch AI",
|
| 444 |
"short_name": "PawMatch",
|
| 445 |
"start_url": ".",
|
|
|
|
| 453 |
"type": "image/png"
|
| 454 |
}
|
| 455 |
]
|
| 456 |
+
}'''
|
| 457 |
|
| 458 |
return f"""
|
| 459 |
<!DOCTYPE html>
|
|
|
|
| 462 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
| 463 |
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
| 464 |
<meta name="theme-color" content="#4299e1">
|
| 465 |
+
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' data: blob: https:">
|
| 466 |
|
| 467 |
<script type="application/json" id="pwa-manifest">
|
| 468 |
+
{manifest_content}
|
| 469 |
</script>
|
| 470 |
|
| 471 |
<script>
|
| 472 |
+
window.addEventListener('load', function() {{
|
| 473 |
+
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
| 474 |
+
|
| 475 |
+
if (isSafari) {{
|
| 476 |
+
document.body.classList.add('safari-browser');
|
| 477 |
+
|
| 478 |
+
const fileInputs = document.querySelectorAll('input[type="file"]');
|
| 479 |
+
fileInputs.forEach(input => {{
|
| 480 |
+
input.addEventListener('change', async function(e) {{
|
| 481 |
+
const file = e.target.files[0];
|
| 482 |
+
if (file) {{
|
| 483 |
+
const formData = new FormData();
|
| 484 |
+
formData.append('file', file);
|
| 485 |
+
|
| 486 |
+
try {{
|
| 487 |
+
const response = await fetch('/upload', {{
|
| 488 |
+
method: 'POST',
|
| 489 |
+
body: formData
|
| 490 |
+
}});
|
| 491 |
+
|
| 492 |
+
if (!response.ok) throw new Error('Upload failed');
|
| 493 |
+
|
| 494 |
+
const result = await response.json();
|
| 495 |
+
console.log('Upload successful:', result);
|
| 496 |
+
}} catch (error) {{
|
| 497 |
+
console.error('Upload error:', error);
|
| 498 |
+
}}
|
| 499 |
+
}}
|
| 500 |
+
}});
|
| 501 |
+
}});
|
| 502 |
+
}}
|
| 503 |
+
}});
|
| 504 |
</script>
|
| 505 |
|
| 506 |
<style>
|
| 507 |
+
.safari-browser .file-upload {{
|
| 508 |
+
-webkit-appearance: none;
|
| 509 |
+
appearance: none;
|
| 510 |
+
border-radius: 8px;
|
| 511 |
+
padding: 10px;
|
| 512 |
+
background: #f3f4f6;
|
| 513 |
}}
|
| 514 |
|
| 515 |
+
@media (display-mode: standalone) {{
|
| 516 |
body {{
|
| 517 |
+
padding-top: env(safe-area-inset-top);
|
| 518 |
+
padding-bottom: env(safe-area-inset-bottom);
|
| 519 |
}}
|
| 520 |
}}
|
| 521 |
</style>
|