playerplayerop1's picture
Update app.py
1d917ad verified
Raw History Blame Contribute Delete
943 Bytes
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()