import gradio as gr import time # ------------------------- # 1) API Fonksiyonu # ------------------------- def api_echo(text): return {"status": "success", "message": text} # ------------------------- # 2) Normal Fonksiyon # ------------------------- def hello(name): if not name: return "Lütfen bir isim gir!" return f"Merhaba {name}! Tema, Tabs, API ve Dosya Sistemi aktif." # ------------------------- # 3) Dosya Yükleme Fonksiyonu # ------------------------- def file_info(file): if file is None: return "Dosya yok!" return f"Dosya alındı: {file.name} - Boyut: {file.size} byte" # --------------------------------------------------- # GRADIO BLOCKS (Tema + Tabs + Modern Tasarım) # --------------------------------------------------- with gr.Blocks(theme="soft", css=""" body { background: #0d1117 !important; color: white !important; } .gr-button { border-radius: 12px !important; } """) as demo: gr.Markdown(""" # ⚡ **Gelişmiş Zero-Model Space** Sıfır model • Çoklu sayfa • API sistemi • Dosya yükleme. """) with gr.Tabs(): # --------------------- TAB 1 --------------------- with gr.Tab("👤 Karşılama Ekranı"): gr.Markdown("### Burada isim yazıp selamlama alacaksın.") name = gr.Textbox(label="Adını Yaz") btn = gr.Button("Gönder") out = gr.Textbox(label="Cevap") btn.click(hello, inputs=name, outputs=out) # --------------------- TAB 2 --------------------- with gr.Tab("📂 Dosya Yükleme"): gr.Markdown("### Her türlü dosyayı yükleyebilirsin.") uploaded = gr.File(label="Dosya Seç") file_btn = gr.Button("Dosyayı İşle") file_out = gr.Textbox(label="Dosya Bilgisi") file_btn.click(file_info, inputs=uploaded, outputs=file_out) # --------------------- TAB 3 --------------------- with gr.Tab("🛰 API Endpoint"): gr.Markdown(""" ### API Nasıl Kullanılır? Bu Space kendi API sistemine sahiptir. **Example Request (Python):** ```python import requests url = "https://YOUR-SPACE-NAME.hf.space/run/api" r = requests.post(url, json={"text": "Selam API!"}) print(r.json()) ``` """) api_text = gr.Textbox(label="API'ye Gönderilecek Metin") api_btn = gr.Button("API Çalıştır") api_out = gr.JSON(label="API Çıktısı") api_btn.click(api_echo, inputs=api_text, outputs=api_out) demo.launch()