fix
Browse filesFiles changed (2)
919 unmodified lines920921922923924925926216 unmodified lines1143114411451146114711482 unmodified lines11511152115311541155115611571158919 unmodified linesfor filename, content in files.items():file_path = temp_path / filenameprint(f"[Deploy] Writing {filename} ({len(content)} chars) to {file_path}")file_path.write_text(content, encoding='utf-8')# Verify the write was successfulwritten_size = file_path.stat().st_sizeprint(f"[Deploy] Verified {filename}: {written_size} bytes on disk")216 unmodified linesif not file_content:return False, f"Missing content for {file_name}", Nonesuccess = Falselast_error = None2 unmodified linestry:# 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)f.flush() # Ensure all content is written to disk before closingtemp_file_path = f.name# File is now closed and flushed, safe to upload919 unmodified lines920921922923924925926927928929930931932216 unmodified lines1149115011511152115311541155115611571158115911601161116211632 unmodified lines116611671168116911701171117211731174919 unmodified linesfor filename, content in files.items():file_path = temp_path / filenameprint(f"[Deploy] Writing {filename} ({len(content)} chars) to {file_path}")# Use binary mode with UTF-8 encoding for better emoji/special character handlingtry: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 charactersfile_path.write_bytes(content.encode('utf-8', errors='ignore'))# Verify the write was successfulwritten_size = file_path.stat().st_sizeprint(f"[Deploy] Verified {filename}: {written_size} bytes on disk")216 unmodified linesif 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 earlyfile_content.encode('utf-8', errors='strict')except UnicodeEncodeError as e:print(f"[Deploy] Encoding warning for {file_name}: {e}")# Replace problematic characters with safe equivalentsfile_content = file_content.encode('utf-8', errors='ignore').decode('utf-8')success = Falselast_error = None2 unmodified linestry:# 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")# Use binary mode with explicit UTF-8 encoding for better emoji handlingwith 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 closingtemp_file_path = f.name# File is now closed and flushed, safe to upload
73 unmodified lines74757677787996 unmodified lines17617717817918018173 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" comments**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 failureIMPORTANT: 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"""73 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 insteadIMPORTANT: 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