Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -645,7 +645,6 @@ def optimize_code(code: str) -> str:
|
|
645 |
logger.debug(f"Optimized code length: {len(cleaned_code)}")
|
646 |
return cleaned_code
|
647 |
|
648 |
-
|
649 |
def send_to_sandbox(code):
|
650 |
"""Encodes HTML code for display in an iframe sandbox."""
|
651 |
logger.debug(f"Preparing code for sandbox (length: {len(code)})")
|
@@ -663,20 +662,23 @@ def send_to_sandbox(code):
|
|
663 |
logger.debug("Wrapping code in basic HTML structure for sandbox.")
|
664 |
# Check if body tags exist, if not, wrap the whole thing
|
665 |
if not re.search(r'<body.*?>', clean_code, re.IGNORECASE):
|
|
|
666 |
clean_code = f"""<!DOCTYPE html>
|
667 |
<html lang="en">
|
668 |
<head>
|
669 |
<meta charset="UTF-8">
|
670 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
671 |
<title>Game Preview</title>
|
672 |
-
<style>body {{ margin: 0; overflow: hidden; }}</style>
|
673 |
</head>
|
674 |
<body>
|
675 |
{clean_code}
|
676 |
</body>
|
677 |
</html>"""
|
|
|
678 |
else:
|
679 |
# If body exists, just ensure doctype and html/head are present
|
|
|
680 |
clean_code = f"""<!DOCTYPE html>
|
681 |
<html lang="en">
|
682 |
<head>
|
@@ -687,6 +689,7 @@ def send_to_sandbox(code):
|
|
687 |
</head>
|
688 |
{clean_code}
|
689 |
</html>"""
|
|
|
690 |
|
691 |
|
692 |
try:
|
@@ -701,6 +704,8 @@ def send_to_sandbox(code):
|
|
701 |
except Exception as e:
|
702 |
logger.error(f"Error encoding HTML for sandbox: {e}", exc_info=True)
|
703 |
return f"<p style='color: red;'>Error creating sandbox preview: {html.escape(str(e))}</p>"
|
|
|
|
|
704 |
|
705 |
|
706 |
def boost_prompt(prompt: str) -> str:
|
|
|
645 |
logger.debug(f"Optimized code length: {len(cleaned_code)}")
|
646 |
return cleaned_code
|
647 |
|
|
|
648 |
def send_to_sandbox(code):
|
649 |
"""Encodes HTML code for display in an iframe sandbox."""
|
650 |
logger.debug(f"Preparing code for sandbox (length: {len(code)})")
|
|
|
662 |
logger.debug("Wrapping code in basic HTML structure for sandbox.")
|
663 |
# Check if body tags exist, if not, wrap the whole thing
|
664 |
if not re.search(r'<body.*?>', clean_code, re.IGNORECASE):
|
665 |
+
# --- 수정된 부분: f-string 내 주석 제거 ---
|
666 |
clean_code = f"""<!DOCTYPE html>
|
667 |
<html lang="en">
|
668 |
<head>
|
669 |
<meta charset="UTF-8">
|
670 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
671 |
<title>Game Preview</title>
|
672 |
+
<style>body {{ margin: 0; overflow: hidden; }}</style>
|
673 |
</head>
|
674 |
<body>
|
675 |
{clean_code}
|
676 |
</body>
|
677 |
</html>"""
|
678 |
+
# --- 수정 끝 ---
|
679 |
else:
|
680 |
# If body exists, just ensure doctype and html/head are present
|
681 |
+
# --- 수정된 부분: f-string 내 주석 제거 (else 블록도 확인) ---
|
682 |
clean_code = f"""<!DOCTYPE html>
|
683 |
<html lang="en">
|
684 |
<head>
|
|
|
689 |
</head>
|
690 |
{clean_code}
|
691 |
</html>"""
|
692 |
+
# --- 수정 끝 ---
|
693 |
|
694 |
|
695 |
try:
|
|
|
704 |
except Exception as e:
|
705 |
logger.error(f"Error encoding HTML for sandbox: {e}", exc_info=True)
|
706 |
return f"<p style='color: red;'>Error creating sandbox preview: {html.escape(str(e))}</p>"
|
707 |
+
|
708 |
+
|
709 |
|
710 |
|
711 |
def boost_prompt(prompt: str) -> str:
|