WebSim Project Creator
AI
Enter your project description and let AI generate your web project
Generate Project
Generating your project...
Back to Editor
Update
View Code
Source Code
Copy
Download
Close
') || !code.includes('/g) || []).length || (code.match(/{/g) || []).length !== (code.match(/}/g) || []).length; if (needsCompletion && !attemptedCompletion) { attemptedCompletion = true; try { const completion = await fetch('https://gen.pollinations.ai/text/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ messages: [{ role: "user", content: `CONTEXT: Complete this HTML code and add any missing parts. Current code: ${currentCode} Requirements: 1. Complete all open tags and functions 2. Ensure all script blocks are complete 3. Keep all existing functionality 4. Only add what's missing to complete the code OUTPUT: Complete valid HTML only, no explanations.` }], max_tokens: 4000, model: 'openai' }) }); const completedCode = await completion.text(); return extractCode(completedCode); } catch (error) { console.error('Completion error:', error); return currentCode; // Return original code if completion fails } } return currentCode; } function extractCode(response) { let code = response; if (code.includes('```html')) { code = code.split('```html')[1].split('```')[0].trim(); } else if (code.includes('```')) { code = code.split('```')[1].split('```')[0].trim(); } return code; } async function generateProject() { const prompt = document.getElementById('prompt').value; if (!prompt) { alert('Please enter a project description'); return; } document.getElementById('error').style.display = 'none'; document.getElementById('loading').style.display = 'block'; document.getElementById('projectView').style.display = 'block'; try { const response = await fetch('https://gen.pollinations.ai/text/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ messages: [{ role: "user", content: `CONTEXT: Create a complete web project. ${API_CONTEXT}\n\nUSER: ${prompt}` }], max_tokens: 4000, model: 'openai' }) }); if (!response.ok) { throw new Error('API response was not ok'); } const result = await response.text(); let code = extractCode(result); // Simple completion check and fix if (!code.includes('