Download app.py from Fffffd/Ai_beyin: direct link, hf CLI and curl.
- Browser
- Download file 890 Bytes
-
https://huggingface.co/Fffffd/Ai_beyin/resolve/main/app.py
- Command line
-
hf download hf://Fffffd/Ai_beyin/app.py
-
curl -L -o app.py https://huggingface.co/Fffffd/Ai_beyin/resolve/main/app.py
890 Bytes
| # HuggingFace Space'e yüklenecek olan app.py (Sunucu Tarafı) | |
| import asyncio | |
| import websockets | |
| import pickle | |
| from huggingface_hub import hf_hub_download | |
| # 1. Beyni bir kez yükle | |
| print("🧠 Beyin yükleniyor...") | |
| beyin_dosyasi = hf_hub_download(repo_id="Fffffd/Ai_beyin", filename="dexo_brain.pkl") | |
| with open(beyin_dosyasi, 'rb') as f: | |
| dexo_model = pickle.load(f) | |
| print("✅ Beyin sunucuda hazır!") | |
| async def handler(websocket): | |
| async for message in websocket: | |
| # Gelen mesajı işle (Burada kendi yapay zeka mantığını çalıştır) | |
| cevap = f"Dexo İşledi: {message}" | |
| await websocket.send(cevap) | |
| async def main(): | |
| # HuggingFace Space üzerinde otomatik 7860 portunu kullanır | |
| async with websockets.serve(handler, "0.0.0.0", 7860): | |
| await asyncio.Future() # Sürekli çalış | |
| if __name__ == "__main__": | |
| asyncio.run(main()) | |