update
Browse files1110 unmodified lines1111111211131114111511168 unmodified lines11251126112711281129113011311110 unmodified linesif not files:return gr.update(value="Error: Could not parse React output. Please regenerate the code.", visible=True)# Upload React filesimport tempfileimport time8 unmodified linesfor attempt in range(max_attempts):try:with tempfile.NamedTemporaryFile("w", suffix=f".{file_name.split('.')[-1]}", delete=False) as f:f.write(file_content)temp_path = f.name1110 unmodified lines111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711488 unmodified lines11571158115911601161116211631164116511661167116811691110 unmodified linesif not files:return gr.update(value="Error: Could not parse React output. Please regenerate the code.", visible=True)# If Dockerfile is missing, use templateif 'Dockerfile' not in files:files['Dockerfile'] = """FROM node:18-slim# Set up user with ID 1000RUN useradd -m -u 1000 userUSER userENV HOME=/home/user \\PATH=/home/user/.local/bin:$PATH# Set working directoryWORKDIR $HOME/app# Copy package files with proper ownershipCOPY --chown=user package*.json ./# Install dependenciesRUN npm install# Copy rest of the application with proper ownershipCOPY --chown=user . .# Build the Next.js appRUN npm run build# Expose port 7860EXPOSE 7860# Start the application on port 7860CMD ["npm", "start", "--", "-p", "7860"]"""# Upload React filesimport tempfileimport time8 unmodified linesfor attempt in range(max_attempts):try:# Determine file extensionif file_name == 'Dockerfile':suffix = ''else:suffix = f".{file_name.split('.')[-1]}"with tempfile.NamedTemporaryFile("w", suffix=suffix, delete=False) as f:f.write(file_content)temp_path = f.name
anycoder_app/ui.py+39-1