File size: 2,660 Bytes
4f25db8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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()