fix
Browse filesFiles changed (2)
919 unmodified lines920921922923923924925926927928929930931932216 unmodified lines1149115011511152115311541155115611571158115911601161116211632 unmodified lines11661167116811541155116911701171117211731174919 unmodified lines for filename, content in files.items(): file_path = temp_path / filename print(f"[Deploy] Writing {filename} ({len(content)} chars) to {file_path}") file_path.write_text(content, encoding='utf-8') # Use binary mode with UTF-8 encoding for better emoji/special character handling try: file_path.write_bytes(content.encode('utf-8')) except UnicodeEncodeError as e: print(f"[Deploy] Encoding error in {filename}: {e}, using fallback encoding") # Fallback: ignore problematic characters file_path.write_bytes(content.encode('utf-8', errors='ignore')) # Verify the write was successful written_size = file_path.stat().st_size print(f"[Deploy] Verified {filename}: {written_size} bytes on disk")216 unmodified lines if not file_content: return False, f"Missing content for {file_name}", None # Ensure content is properly encoded (handle emojis safely) try: # Test encoding - this will catch any encoding issues early file_content.encode('utf-8', errors='strict') except UnicodeEncodeError as e: print(f"[Deploy] Encoding warning for {file_name}: {e}") # Replace problematic characters with safe equivalents file_content = file_content.encode('utf-8', errors='ignore').decode('utf-8') success = False last_error = None 2 unmodified lines try: # Create a NEW temp file for this upload (key difference from old approach) print(f"[Deploy] Creating temp file for {file_name} with {len(file_content)} chars") with tempfile.NamedTemporaryFile("w", suffix=f".{file_name.split('.')[-1]}", delete=False, encoding='utf-8') as f: f.write(file_content) # Use binary mode with explicit UTF-8 encoding for better emoji handling with tempfile.NamedTemporaryFile("wb", suffix=f".{file_name.split('.')[-1]}", delete=False) as f: f.write(file_content.encode('utf-8')) f.flush() # Ensure all content is written to disk before closing temp_file_path = f.name # File is now closed and flushed, safe to upload73 unmodified lines7475767778798096 unmodified lines17717817918018118218373 unmodified lines5. **ONLY use the === filename === markers** - do not add any other formatting6. Add a blank line between each file section7. Each file must be complete and ready to deploy - no placeholders or "// TODO" comments8. **AVOID EMOJIS in the generated code** (HTML/JS/CSS files) - use text or unicode symbols instead for deployment compatibility
**WRONG FORMAT (DO NOT DO THIS):**<!DOCTYPE html>96 unmodified lines3. ALL THREE files must be complete and functional - no placeholders or "TODO" comments4. Start each file's content immediately on the line after the === marker5. Ensure each file has actual content - empty files will cause deployment failure6. AVOID using emojis in the generated code files - use text or HTML entities instead
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""
backend_deploy.py+19-3
backend_prompts.py+2