// Resim üretimi — app'in GERÇEK kodu → ComfyUI → png. import 'dart:convert'; import 'dart:io'; import '../lib/comfy/workflow/resim_workflow.dart'; Future main() async { const base = 'http://127.0.0.1:8188'; final http = HttpClient(); final p = ResimParametreleri( prompt: 'cinematic portrait of a turkish woman, golden hour, bokeh', seed: 0, genislik: 768, yukseklik: 1024, steps: 18, guidance: 3.5, ); final wf = resimWorkflowOlustur(p); stdout.writeln('SaveImage node: ${wf['8']?['class_type']}'); Future> post(String y, Map g) async { final i = await http.postUrl(Uri.parse('$base$y')); i.headers.contentType = ContentType.json; i.write(jsonEncode(g)); final c = await i.close(); return jsonDecode(await c.transform(utf8.decoder).join()) as Map; } Future> get(String y) async { final i = await http.getUrl(Uri.parse('$base$y')); final c = await i.close(); return jsonDecode(await c.transform(utf8.decoder).join()) as Map; } final r = await post('/prompt', {'prompt': wf, 'client_id': 'fikoyt-e2eimg'}); if (r['error'] != null) { stdout.writeln('RED: ${jsonEncode(r['error'])}'); exit(1); } final pid = r['prompt_id'] as String; stdout.writeln('prompt_id: $pid'); for (var i = 0; i < 90; i++) { await Future.delayed(const Duration(seconds: 4)); final h = await get('/history/$pid'); final k = h[pid] as Map?; if (k == null) continue; final st = k['status'] as Map?; if (st?['status_str'] == 'error') { stdout.writeln('HATA: ${jsonEncode(st)}'); exit(1); } if (st?['completed'] == true) { stdout.writeln('BASARILI: ${jsonEncode(k['outputs'])}'); exit(0); } } stdout.writeln('ZAMAN ASIMI'); exit(1); }