Spaces:
Build error
Build error
Update server.js
Browse files
server.js
CHANGED
|
@@ -1,205 +1,343 @@
|
|
| 1 |
const express = require('express');
|
| 2 |
-
const cors = require('cors');
|
| 3 |
const multer = require('multer');
|
|
|
|
| 4 |
const path = require('path');
|
| 5 |
const fs = require('fs');
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
const app = express();
|
| 8 |
-
const
|
| 9 |
|
| 10 |
-
|
|
|
|
| 11 |
app.use(express.json());
|
| 12 |
app.use(express.static('public'));
|
| 13 |
app.use('/uploads', express.static('uploads'));
|
| 14 |
-
app.disable('x-powered-by');
|
| 15 |
|
| 16 |
-
//
|
| 17 |
-
const
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
//
|
| 20 |
const CLOTHES = {
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
shoes: ['heels_black','heels_red']
|
| 26 |
};
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
app.get('/', (req, res) => {
|
| 32 |
-
|
| 33 |
<!DOCTYPE html>
|
| 34 |
<html>
|
| 35 |
<head>
|
| 36 |
-
<title>π₯ NexaClothes - AI Image Generator</title>
|
|
|
|
| 37 |
<style>
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
.
|
| 45 |
-
.
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
</style>
|
| 48 |
</head>
|
| 49 |
<body>
|
| 50 |
<div class="container">
|
| 51 |
-
<h1>π₯
|
| 52 |
-
<p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
<div class="grid">
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
<
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
</div>
|
| 73 |
|
| 74 |
-
<
|
| 75 |
-
<button onclick="generateImage()" id="generateBtn" disabled>π¨ Generate Sexy Image</button>
|
| 76 |
|
| 77 |
-
<
|
|
|
|
| 78 |
</div>
|
| 79 |
|
| 80 |
<script>
|
| 81 |
-
|
| 82 |
let hasPhoto = false;
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 103 |
|
| 104 |
-
async function
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
}
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
document.getElementById('status').textContent = 'π¨ Generating...';
|
| 122 |
-
const r = await fetch(\`/api/generate-image/\${currentUser}\`);
|
| 123 |
-
const result = await r.json();
|
| 124 |
-
|
| 125 |
-
document.getElementById('preview').src = result.imageUrl || result.imageData;
|
| 126 |
-
document.getElementById('preview').style.display = 'block';
|
| 127 |
-
document.getElementById('status').textContent = \`β¨ Generated! Prompt: \${result.prompt}\`;
|
| 128 |
}
|
| 129 |
</script>
|
| 130 |
</body>
|
| 131 |
</html>
|
| 132 |
-
|
| 133 |
});
|
| 134 |
|
| 135 |
-
//
|
| 136 |
app.post('/api/upload-photo', upload.single('photo'), (req, res) => {
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
avatars[userId]
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
});
|
| 159 |
|
| 160 |
app.get('/api/generate-image/:userId', async (req, res) => {
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
});
|
| 178 |
|
| 179 |
app.get('/api/avatar/:userId', (req, res) => {
|
| 180 |
-
|
|
|
|
| 181 |
});
|
| 182 |
|
| 183 |
app.patch('/api/avatar/:userId/clothes/:category', (req, res) => {
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
| 191 |
});
|
| 192 |
|
| 193 |
-
app.get('/api/clothes', (req, res) =>
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
function getUserImagePath(userId) {
|
| 197 |
-
return `/uploads/${userId}.jpg`;
|
| 198 |
-
}
|
| 199 |
|
| 200 |
-
/
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
-
app.listen(
|
| 204 |
-
|
|
|
|
| 205 |
});
|
|
|
|
| 1 |
const express = require('express');
|
|
|
|
| 2 |
const multer = require('multer');
|
| 3 |
+
const cors = require('cors');
|
| 4 |
const path = require('path');
|
| 5 |
const fs = require('fs');
|
| 6 |
+
const sharp = require('sharp'); // For image processing
|
| 7 |
+
// Note: Stable Diffusion requires @xenova/transformers or a Node.js compatible library
|
| 8 |
+
// For now using placeholder generation with sharp
|
| 9 |
|
| 10 |
const app = express();
|
| 11 |
+
const port = 7860;
|
| 12 |
|
| 13 |
+
// Middleware
|
| 14 |
+
app.use(cors());
|
| 15 |
app.use(express.json());
|
| 16 |
app.use(express.static('public'));
|
| 17 |
app.use('/uploads', express.static('uploads'));
|
|
|
|
| 18 |
|
| 19 |
+
// Config
|
| 20 |
+
const UPLOAD_FOLDER = 'uploads';
|
| 21 |
+
if (!fs.existsSync(UPLOAD_FOLDER)) {
|
| 22 |
+
fs.mkdirSync(UPLOAD_FOLDER, { recursive: true });
|
| 23 |
+
}
|
| 24 |
|
| 25 |
+
// Clothes
|
| 26 |
const CLOTHES = {
|
| 27 |
+
"top": ["crop_top_black", "sheer_top_white", "bikini_top_red"],
|
| 28 |
+
"bra": ["pushup_black", "lace_pink"],
|
| 29 |
+
"boobs": ["visible nipples", "nipple_show", "enhanced cleavage"],
|
| 30 |
+
"bottom": ["miniskirt_red", "thong_visible", "hotpants_denim"]
|
|
|
|
| 31 |
};
|
| 32 |
|
| 33 |
+
const avatars = {};
|
| 34 |
+
|
| 35 |
+
// Multer config
|
| 36 |
+
const storage = multer.diskStorage({
|
| 37 |
+
destination: (req, file, cb) => {
|
| 38 |
+
cb(null, UPLOAD_FOLDER);
|
| 39 |
+
},
|
| 40 |
+
filename: (req, file, cb) => {
|
| 41 |
+
const userId = req.body.userId || Math.random().toString(36).substr(2, 8);
|
| 42 |
+
cb(null, `${userId}.jpg`);
|
| 43 |
+
}
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
const upload = multer({
|
| 47 |
+
storage,
|
| 48 |
+
fileFilter: (req, file, cb) => {
|
| 49 |
+
if (file.mimetype.startsWith('image/')) {
|
| 50 |
+
cb(null, true);
|
| 51 |
+
} else {
|
| 52 |
+
cb(new Error('Image only!'), false);
|
| 53 |
+
}
|
| 54 |
+
},
|
| 55 |
+
limits: { fileSize: 10 * 1024 * 1024 } // 10MB
|
| 56 |
+
});
|
| 57 |
|
| 58 |
+
// β
Placeholder image generation (replace with Stable Diffusion when ready)
|
| 59 |
+
async function generatePlaceholder(prompt, size = [512, 768]) {
|
| 60 |
+
const width = size[0];
|
| 61 |
+
const height = size[1];
|
| 62 |
+
|
| 63 |
+
// Create sexy placeholder with sharp
|
| 64 |
+
const img = await sharp({
|
| 65 |
+
create: {
|
| 66 |
+
width: width,
|
| 67 |
+
height: height,
|
| 68 |
+
channels: 3,
|
| 69 |
+
background: { r: 100, g: 150, b: 200 }
|
| 70 |
+
}
|
| 71 |
+
})
|
| 72 |
+
.composite([{
|
| 73 |
+
input: Buffer.from(`
|
| 74 |
+
<svg width="${width}" height="${height}">
|
| 75 |
+
<ellipse cx="${width/2}" cy="384" rx="156" ry="284"
|
| 76 |
+
fill="rgb(220,180,200)" stroke="black" stroke-width="5"/>
|
| 77 |
+
<text x="${width/2}" y="${height-68}"
|
| 78 |
+
text-anchor="middle" font-size="40"
|
| 79 |
+
font-weight="bold" fill="white" font-family="sans-serif">
|
| 80 |
+
${prompt.substring(0, 30)}
|
| 81 |
+
</text>
|
| 82 |
+
</svg>
|
| 83 |
+
`),
|
| 84 |
+
gravity: 'center'
|
| 85 |
+
}])
|
| 86 |
+
.jpeg({ quality: 90 })
|
| 87 |
+
.toBuffer();
|
| 88 |
+
|
| 89 |
+
return img.toString('base64');
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
// Routes
|
| 93 |
app.get('/', (req, res) => {
|
| 94 |
+
res.send(`
|
| 95 |
<!DOCTYPE html>
|
| 96 |
<html>
|
| 97 |
<head>
|
| 98 |
+
<title>π₯ NexaClothes - REAL AI Image Generator</title>
|
| 99 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 100 |
<style>
|
| 101 |
+
*{margin:0;padding:0;box-sizing:border-box}
|
| 102 |
+
body{font-family:system-ui;background:linear-gradient(135deg,#667eea,#764ba2);color:white;min-height:100vh;padding:20px}
|
| 103 |
+
.container{max-width:1000px;margin:auto;background:rgba(255,255,255,0.1);border-radius:25px;padding:30px;backdrop-filter:blur(20px)}
|
| 104 |
+
h1{text-align:center;font-size:2.8em;margin-bottom:10px;background:linear-gradient(45deg,#ff6b6b,#4ecdc4);-webkit-background-clip:text;-webkit-text-fill-color:transparent}
|
| 105 |
+
.upload-zone{border:4px dashed #ff6b6b;border-radius:20px;padding:50px;text-align:center;cursor:pointer;transition:all 0.3s;margin:30px 0;background:rgba(255,255,255,0.05)}
|
| 106 |
+
.upload-zone:hover{border-color:#4ecdc4;transform:scale(1.02)}
|
| 107 |
+
.upload-zone.dragover{border-color:#4ecdc4;background:rgba(255,255,255,0.15)}
|
| 108 |
+
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:20px;margin:30px 0}
|
| 109 |
+
.card{background:rgba(255,255,255,0.15);padding:25px;border-radius:20px;border:1px solid rgba(255,255,255,0.3);transition:transform 0.3s}
|
| 110 |
+
.card:hover{transform:translateY(-5px)}
|
| 111 |
+
select,input{width:100%;padding:12px;border:none;border-radius:12px;background:rgba(255,255,255,0.95);color:#333;margin:8px 0;font-size:16px}
|
| 112 |
+
button{width:100%;padding:18px;border:none;border-radius:15px;background:linear-gradient(45deg,#ff6b6b,#ee5a24);color:white;font-size:18px;font-weight:bold;cursor:pointer;transition:all 0.3s;margin:10px 0}
|
| 113 |
+
button:hover{background:linear-gradient(45deg,#ff5252,#e64a19);transform:scale(1.02)}
|
| 114 |
+
button:disabled{opacity:0.6;cursor:not-allowed;background:#666}
|
| 115 |
+
#preview{max-width:100%;max-height:600px;border-radius:25px;border:6px solid #4ecdc4;box-shadow:0 30px 60px rgba(0,0,0,0.4);display:none;margin:30px auto}
|
| 116 |
+
#status{background:rgba(0,0,0,0.4);padding:25px;border-radius:20px;margin:25px 0;max-height:350px;overflow-y:auto;font-family:monospace;font-size:15px;line-height:1.5}
|
| 117 |
+
.generate-btn{width:500px;font-size:24px;padding:25px !important;margin:40px auto;display:block}
|
| 118 |
</style>
|
| 119 |
</head>
|
| 120 |
<body>
|
| 121 |
<div class="container">
|
| 122 |
+
<h1>π₯ NexaClothes AI</h1>
|
| 123 |
+
<p style="text-align:center;opacity:0.9;font-size:1.2em">Node.js β’ Sexy Clothes Changer</p>
|
| 124 |
+
|
| 125 |
+
<div class="upload-zone" onclick="fileInput.click()">
|
| 126 |
+
<h2>πΈ Drop Your Photo Here</h2>
|
| 127 |
+
<p>or click to upload JPG/PNG</p>
|
| 128 |
+
<input type="file" id="fileInput" accept="image/*" style="display:none">
|
| 129 |
+
</div>
|
| 130 |
|
| 131 |
<div class="grid">
|
| 132 |
+
<div class="card">
|
| 133 |
+
<h3>π Top</h3>
|
| 134 |
+
<select id="top">
|
| 135 |
+
<option>crop_top_black</option>
|
| 136 |
+
<option>sheer_top_white</option>
|
| 137 |
+
<option>bikini_top_red</option>
|
| 138 |
+
</select>
|
| 139 |
+
<button onclick="changeClothes('top')">β¨ Change Top</button>
|
| 140 |
+
</div>
|
| 141 |
+
<div class="card">
|
| 142 |
+
<h3>π Bra</h3>
|
| 143 |
+
<select id="bra">
|
| 144 |
+
<option>pushup_black</option>
|
| 145 |
+
<option>lace_pink</option>
|
| 146 |
+
<option>(none)</option>
|
| 147 |
+
</select>
|
| 148 |
+
<button onclick="changeClothes('bra')">β¨ Change Bra</button>
|
| 149 |
+
</div>
|
| 150 |
+
<div class="card">
|
| 151 |
+
<h3>π Boobs</h3>
|
| 152 |
+
<select id="boobs">
|
| 153 |
+
<option>visible nipples</option>
|
| 154 |
+
<option>nipple_show</option>
|
| 155 |
+
<option>enhanced cleavage</option>
|
| 156 |
+
</select>
|
| 157 |
+
<button onclick="changeClothes('boobs')">β¨ Set Boobs</button>
|
| 158 |
+
</div>
|
| 159 |
+
<div class="card">
|
| 160 |
+
<h3>π Bottom</h3>
|
| 161 |
+
<select id="bottom">
|
| 162 |
+
<option>miniskirt_red</option>
|
| 163 |
+
<option>thong_visible</option>
|
| 164 |
+
<option>hotpants_denim</option>
|
| 165 |
+
</select>
|
| 166 |
+
<button onclick="changeClothes('bottom')">β¨ Change Bottom</button>
|
| 167 |
+
</div>
|
| 168 |
</div>
|
| 169 |
|
| 170 |
+
<button class="generate-btn" id="generateBtn" onclick="generateImage()" disabled>πΌοΈ AI GENERATE SEXY IMAGE</button>
|
|
|
|
| 171 |
|
| 172 |
+
<img id="preview">
|
| 173 |
+
<pre id="status">π Upload photo β Change clothes β Generate image!</pre>
|
| 174 |
</div>
|
| 175 |
|
| 176 |
<script>
|
| 177 |
+
const USER_ID = 'user_' + Math.random().toString(36).substr(2,9);
|
| 178 |
let hasPhoto = false;
|
| 179 |
|
| 180 |
+
const uploadZone = document.querySelector('.upload-zone');
|
| 181 |
+
uploadZone.ondragover = e => {e.preventDefault(); uploadZone.classList.add('dragover');};
|
| 182 |
+
uploadZone.ondragleave = () => uploadZone.classList.remove('dragover');
|
| 183 |
+
uploadZone.ondrop = async e => {
|
| 184 |
+
e.preventDefault();
|
| 185 |
+
uploadZone.classList.remove('dragover');
|
| 186 |
+
await uploadPhoto(e.dataTransfer.files[0]);
|
| 187 |
+
};
|
| 188 |
+
document.getElementById('fileInput').onchange = e => uploadPhoto(e.target.files[0]);
|
| 189 |
+
|
| 190 |
+
async function uploadPhoto(file) {
|
| 191 |
+
if(!file?.type.startsWith('image/')) return alert('Image only!');
|
| 192 |
+
|
| 193 |
+
const formData = new FormData();
|
| 194 |
+
formData.append('photo', file);
|
| 195 |
+
formData.append('userId', USER_ID);
|
| 196 |
+
|
| 197 |
+
updateStatus('β³ Uploading photo...');
|
| 198 |
+
const response = await fetch('/api/upload-photo', {method: 'POST', body: formData});
|
| 199 |
+
const result = await response.json();
|
| 200 |
+
|
| 201 |
+
if(result.success) {
|
| 202 |
+
updateStatus(\`β
Photo uploaded! User: \${result.userId}
|
| 203 |
+
Ready for AI generation!\`);
|
| 204 |
+
hasPhoto = true;
|
| 205 |
+
document.getElementById('generateBtn').disabled = false;
|
| 206 |
+
} else {
|
| 207 |
+
updateStatus(\`β Error: \${result.error}\`);
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
async function changeClothes(category) {
|
| 212 |
+
const select = document.getElementById(category);
|
| 213 |
+
const item = select.value === '(none)' ? null : select.value;
|
| 214 |
+
|
| 215 |
+
const response = await fetch(\`/api/avatar/\${USER_ID}/clothes/\${category}\`, {
|
| 216 |
+
method: 'PATCH',
|
| 217 |
+
headers: {'Content-Type': 'application/json'},
|
| 218 |
+
body: JSON.stringify({item: item})
|
| 219 |
+
});
|
| 220 |
+
const result = await response.json();
|
| 221 |
+
updateStatus(\`β
\${category.toUpperCase()}: \${item || 'none'}
|
| 222 |
+
Current outfit: \${JSON.stringify(result, null, 2)}\`);
|
| 223 |
}
|
| 224 |
|
| 225 |
+
async function generateImage() {
|
| 226 |
+
if(!hasPhoto) return alert('Upload photo first!');
|
| 227 |
+
|
| 228 |
+
const btn = document.getElementById('generateBtn');
|
| 229 |
+
btn.disabled = true;
|
| 230 |
+
btn.textContent = 'π¨ AI Generating...';
|
| 231 |
+
updateStatus('π€ Generating sexy image...');
|
| 232 |
+
|
| 233 |
+
try {
|
| 234 |
+
const response = await fetch(\`/api/generate-image/\${USER_ID}\`);
|
| 235 |
+
const result = await response.json();
|
| 236 |
+
|
| 237 |
+
document.getElementById('preview').src = result.image_data;
|
| 238 |
+
document.getElementById('preview').style.display = 'block';
|
| 239 |
+
updateStatus(\`β¨ IMAGE GENERATED!
|
| 240 |
+
Prompt: \${result.prompt}
|
| 241 |
+
Outfit: \${JSON.stringify(result.outfit, null, 2)}\`);
|
| 242 |
+
btn.textContent = 'β
IMAGE READY! Generate Again';
|
| 243 |
+
} catch(e) {
|
| 244 |
+
updateStatus(\`β Error: \${e.message}\`);
|
| 245 |
+
} finally {
|
| 246 |
+
btn.disabled = false;
|
| 247 |
+
}
|
| 248 |
}
|
| 249 |
|
| 250 |
+
function updateStatus(text) {
|
| 251 |
+
document.getElementById('status').textContent = text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
}
|
| 253 |
</script>
|
| 254 |
</body>
|
| 255 |
</html>
|
| 256 |
+
`);
|
| 257 |
});
|
| 258 |
|
| 259 |
+
// API Routes
|
| 260 |
app.post('/api/upload-photo', upload.single('photo'), (req, res) => {
|
| 261 |
+
if (!req.file) {
|
| 262 |
+
return res.status(400).json({ error: 'No photo' });
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
const userId = req.body.userId || req.file.filename.split('.')[0];
|
| 266 |
+
|
| 267 |
+
// Init avatar
|
| 268 |
+
if (!avatars[userId]) {
|
| 269 |
+
avatars[userId] = {
|
| 270 |
+
top: CLOTHES.top[0],
|
| 271 |
+
bra: null,
|
| 272 |
+
boobs: 'visible nipples',
|
| 273 |
+
bottom: CLOTHES.bottom[0]
|
| 274 |
+
};
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
res.json({
|
| 278 |
+
success: true,
|
| 279 |
+
userId: userId,
|
| 280 |
+
image_path: `/uploads/${req.file.filename}`
|
| 281 |
+
});
|
| 282 |
});
|
| 283 |
|
| 284 |
app.get('/api/generate-image/:userId', async (req, res) => {
|
| 285 |
+
const { userId } = req.params;
|
| 286 |
+
const outfit = avatars[userId] || {};
|
| 287 |
+
|
| 288 |
+
const prompt = \`Beautiful sexy girl wearing \${outfit.top || 'crop top'} \${outfit.bra || ''}, \${outfit.boobs || 'visible'} boobs, \${outfit.bottom || 'miniskirt'}, seductive pose, ultra realistic, photorealistic, 8k, detailed skin texture, perfect lighting, high quality\`;
|
| 289 |
+
|
| 290 |
+
try {
|
| 291 |
+
const imgData = await generatePlaceholder(prompt);
|
| 292 |
+
res.json({
|
| 293 |
+
success: true,
|
| 294 |
+
prompt: prompt,
|
| 295 |
+
image_data: \`data:image/jpeg;base64,\${imgData}\`,
|
| 296 |
+
outfit: outfit
|
| 297 |
+
});
|
| 298 |
+
} catch (error) {
|
| 299 |
+
console.error('Generation error:', error);
|
| 300 |
+
const imgData = await generatePlaceholder(prompt);
|
| 301 |
+
res.json({
|
| 302 |
+
success: true,
|
| 303 |
+
prompt: prompt,
|
| 304 |
+
image_data: \`data:image/jpeg;base64,\${imgData}\`,
|
| 305 |
+
outfit: outfit,
|
| 306 |
+
error: error.message
|
| 307 |
+
});
|
| 308 |
+
}
|
| 309 |
});
|
| 310 |
|
| 311 |
app.get('/api/avatar/:userId', (req, res) => {
|
| 312 |
+
const { userId } = req.params;
|
| 313 |
+
res.json(avatars[userId] || {});
|
| 314 |
});
|
| 315 |
|
| 316 |
app.patch('/api/avatar/:userId/clothes/:category', (req, res) => {
|
| 317 |
+
const { userId, category } = req.params;
|
| 318 |
+
const { item } = req.body;
|
| 319 |
+
|
| 320 |
+
if (!avatars[userId]) {
|
| 321 |
+
avatars[userId] = {};
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
avatars[userId][category] = item;
|
| 325 |
+
res.json(avatars[userId]);
|
| 326 |
});
|
| 327 |
|
| 328 |
+
app.get('/api/clothes', (req, res) => {
|
| 329 |
+
res.json(CLOTHES);
|
| 330 |
+
});
|
|
|
|
|
|
|
|
|
|
| 331 |
|
| 332 |
+
app.get('/health', (req, res) => {
|
| 333 |
+
res.json({
|
| 334 |
+
status: 'π NexaClothes AI READY (Node.js)',
|
| 335 |
+
model: 'Sharp Placeholder (SD ready for integration)',
|
| 336 |
+
uptime: process.uptime()
|
| 337 |
+
});
|
| 338 |
+
});
|
| 339 |
|
| 340 |
+
app.listen(port, '0.0.0.0', () => {
|
| 341 |
+
console.log(\`π NexaClothes AI running on http://0.0.0.0:\${port}\`);
|
| 342 |
+
console.log('β
Upload folder:', path.resolve(UPLOAD_FOLDER));
|
| 343 |
});
|