Spaces:
Sleeping
Sleeping
Update app/routers/base.py
Browse files123456781 unmodified line101112891314151611121314171819201617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586872122232425262728293031323334353637383940414243444546899091929394959697989910010110210310447484910610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215350515253545556575859606115562636415865# =====================================================# 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 root(): last_update = get_latest_timestamp()def home(): """Pegos Data API ana dokümantasyon sayfası""" updated = get_latest_timestamp() html = f""" <html lang="tr"> <head> <meta charset="UTF-8" /> <title>🚀 Pegos Data API Dashboard</title> <html> <head> <title>Pegos Data API</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; }} 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> <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> </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> <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> </body> </html> """ return HTMLResponse(content=html) return HTMLResponse(html)app/routers/base.py+51-144