SamiKoen commited on
Commit
932a3a8
·
verified ·
1 Parent(s): 2cab533

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -9
app.py CHANGED
@@ -720,16 +720,34 @@ demo = gr.ChatInterface(
720
 
721
  # En sondaki if __name__ == "__main__": kısmını tamamen şununla değiştirin:
722
 
 
 
723
  if __name__ == "__main__":
724
- # Ana sayfa için Gradio redirect'i ekle
725
- from fastapi.responses import RedirectResponse
 
726
 
727
- @app.get("/")
728
- async def redirect_to_gradio():
729
- return RedirectResponse(url="/gradio")
730
 
731
- # Gradio'yu /gradio path'inde mount et
732
- app = gr.mount_gradio_app(app, demo, path="/gradio")
 
 
733
 
734
- import uvicorn
735
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
720
 
721
  # En sondaki if __name__ == "__main__": kısmını tamamen şununla değiştirin:
722
 
723
+ # En sondaki if __name__ == "__main__": kısmını tamamen şununla değiştirin:
724
+
725
  if __name__ == "__main__":
726
+ import threading
727
+ import uvicorn
728
+ import time
729
 
730
+ print("🚀 Sunucular başlatılıyor...")
 
 
731
 
732
+ # FastAPI'yi arka planda çalıştır (WhatsApp için)
733
+ def run_fastapi():
734
+ print("📱 WhatsApp API sunucusu başlatılıyor (port 7861)...")
735
+ uvicorn.run(app, host="0.0.0.0", port=7861, log_level="info")
736
 
737
+ # FastAPI thread'ini başlat
738
+ fastapi_thread = threading.Thread(target=run_fastapi, daemon=True)
739
+ fastapi_thread.start()
740
+
741
+ # Biraz bekle ki FastAPI başlasın
742
+ time.sleep(2)
743
+
744
+ print("🌐 Web arayüzü başlatılıyor (port 7860)...")
745
+
746
+ # Ana thread'de Gradio'yu çalıştır (Web arayüzü)
747
+ demo.launch(
748
+ server_name="0.0.0.0",
749
+ server_port=7860,
750
+ share=False,
751
+ debug=True,
752
+ show_error=True
753
+ )