Spaces:
Sleeping
Sleeping
Update app/routers/base.py
Browse files1231 unmodified line56789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158from fastapi import APIRouterfrom fastapi.responses import HTMLResponsefrom app.core.hf_client import get_latest_timestamp1 unmodified linerouter = APIRouter()@router.get("/", response_class=HTMLResponse)def root():last_update = get_latest_timestamp()html = f"""<html lang="tr"><head><meta charset="UTF-8" /><title>🚀 Pegos Data API Dashboard</title><style>body {{font-family: 'Inter', system-ui, sans-serif;background: linear-gradient(135deg, #1a1b26, #2b2c3f);color: #f3f4f6;margin: 0;padding: 30px;}}h1 {{font-size: 2.2em;color: #60a5fa;}}.subtitle {{color: #9ca3af;margin-bottom: 30px;}}.grid {{display: grid;grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));gap: 20px;}}.card {{background: #2d2e42;border-radius: 16px;padding: 20px;box-shadow: 0 4px 12px rgba(0,0,0,0.3);transition: transform 0.2s ease, box-shadow 0.3s;}}.card:hover {{transform: translateY(-4px);box-shadow: 0 6px 16px rgba(0,0,0,0.4);}}h3 {{margin: 0;color: #93c5fd;}}p {{color: #d1d5db;font-size: 0.95em;}}button {{background: #2563eb;color: white;border: none;padding: 8px 14px;border-radius: 8px;cursor: pointer;font-weight: 500;margin-top: 10px;}}button:hover {{background: #1d4ed8;}}pre {{background: rgba(255,255,255,0.07);border-radius: 8px;padding: 10px;font-size: 0.9em;overflow-x: auto;color: #fef3c7;margin-top: 10px;display: none;}}.footer {{margin-top: 40px;font-size: 0.9em;text-align: center;color: #9ca3af;}}a {{color: #93c5fd;text-decoration: none;}}</style><script>async function testEndpoint(endpoint, btn) {{const pre = document.getElementById(endpoint + "_out");pre.style.display = "block";pre.textContent = "⏳ Yükleniyor...";try {{const res = await fetch(endpoint);const data = await res.json();pre.textContent = JSON.stringify(data, null, 2);}} catch (e) {{pre.textContent = "❌ Hata: " + e;}}}}</script></head><body><h1>🚀 Pegos Data API</h1><p class="subtitle">Yapay zekâ destekli blockchain piyasa tahmin API’sine hoş geldiniz.<br>Aşağıda tüm endpoint’leri canlı olarak test edebilirsiniz 👇</p><div class="grid"><div class="card"><h3>🩺 /health</h3><p>API’nin canlılık durumunu kontrol eder.</p><button onclick="testEndpoint('/health', this)">Canlı Test</button><pre id="/health_out"></pre></div><div class="card"><h3>🧩 /latest</h3><p>Son <code>n</code> adet tahmini listeler.<br>Varsayılan: <code>n=50</code></p><button onclick="testEndpoint('/latest?n=5', this)">Canlı Test (n=5)</button><pre id="/latest?n=5_out"></pre></div><div class="card"><h3>📜 /history</h3><p>Geçmiş verileri sayfalama ile getirir.<br>Parametreler: <code>offset</code>, <code>limit</code></p><button onclick="testEndpoint('/history?offset=0&limit=5', this)">Canlı Test (5 kayıt)</button><pre id="/history?offset=0&limit=5_out"></pre></div><div class="card"><h3>📈 /signal</h3><p>Son <code>window</code> tahmine göre piyasa yönünü analiz eder.</p><button onclick="testEndpoint('/signal?window=20', this)">Canlı Test (window=20)</button><pre id="/signal?window=20_out"></pre></div><div class="card"><h3>🤖 /predictions</h3><p>Modelin tahmin ettiği tüm sonuçları JSON formatında döndürür.</p><button onclick="testEndpoint('/predictions', this)">Canlı Test</button><pre id="/predictions_out"></pre></div></div><div class="footer"><p>📦 Dataset: <b>Caner7/pegos-stream</b></p><p>🕒 Son Güncelleme: <b>{last_update}</b></p><p>© 2025 Pegos AI Systems | <a href="https://huggingface.co/Caner7/pegos-stream">Hugging Face Dataset</a></p></div></body></html>"""return HTMLResponse(content=html)123456781 unmodified line1011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465# =====================================================# app/routers/base.py# Ana yönlendirme ve dokümantasyon sayfası# =====================================================from fastapi import APIRouterfrom fastapi.responses import HTMLResponsefrom app.core.hf_client import get_latest_timestamp1 unmodified linerouter = APIRouter()@router.get("/", response_class=HTMLResponse)def home():"""Pegos Data API ana dokümantasyon sayfası"""updated = get_latest_timestamp()html = f"""<html><head><title>Pegos Data API</title><style>body {{background: #0b1221;color: #f1f1f1;font-family: 'Inter', sans-serif;text-align: center;padding: 40px;}}h1 {{ color: #4cc9f0; }}.grid {{display: flex;flex-wrap: wrap;justify-content: center;margin-top: 30px;}}.card {{background: #1a2238;border-radius: 12px;padding: 20px;margin: 10px;width: 250px;box-shadow: 0 0 15px rgba(0,0,0,0.4);transition: transform 0.2s;}}.card:hover {{ transform: scale(1.05); }}a {{ color: #72efdd; text-decoration: none; }}</style></head><body><h1>🚀 Pegos Data API</h1><p>Yapay zekâ destekli blockchain piyasa tahmin servisine hoş geldiniz.</p><p><b>Son Güncelleme:</b> {updated}</p><div class='grid'><div class='card'><a href='/health'>/health</a><br><small>API durumu</small></div><div class='card'><a href='/latest'>/latest</a><br><small>Bugünkü tahminler</small></div><div class='card'><a href='/history'>/history</a><br><small>Geçmiş veriler</small></div><div class='card'><a href='/signal'>/signal</a><br><small>Piyasa yönü</small></div><div class='card'><a href='/predictions'>/predictions</a><br><small>Tahmin detayları</small></div></div><footer style='margin-top:40px;font-size:13px;color:#aaa'>Dataset: <b>Caner7/pegos-stream</b> • {updated}</footer></body></html>"""return HTMLResponse(html)
app/routers/base.py+51-144