File size: 943 Bytes
527e3df
 
 
 
 
1d917ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527e3df
1d917ad
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
import subprocess
import os

def blender_islet(python_kodu):
    # Temizlik
    for f in ["model.glb", "render.png", "exec_script.py"]:
        if os.path.exists(f): os.remove(f)
    
    # Kodu yaz
    with open("exec_script.py", "w") as f:
        f.write(python_kodu)
    
    # Blender'ı çalıştır ve TÜM ÇIKTIYI yakala
    process = subprocess.run(
        ["blender", "--background", "--python", "exec_script.py"],
        capture_output=True,
        text=True
    )
    
    # Blender'ın siyah ekranında ne yazdıysa VS Code'a gönder
    full_log = process.stdout + "\n" + process.stderr
    
    outputs = []
    if os.path.exists("model.glb"): outputs.append("model.glb")
    if os.path.exists("render.png"): outputs.append("render.png")
    
    return full_log, outputs

demo = gr.Interface(
    fn=blender_islet, 
    inputs="text", 
    outputs=["text", "file"], 
    api_name="islet"
)
demo.launch()