"""Chat widget HTML interface for ChatCal.ai.""" from fastapi import APIRouter, Request from fastapi.responses import HTMLResponse router = APIRouter() @router.get("/chat-widget", response_class=HTMLResponse) async def chat_widget(request: Request, email: str = None): """Embeddable chat widget.""" # Force HTTPS for production HuggingFace deployment from app.config import settings if settings.app_env == "production" and "hf.space" in str(request.url.netloc): base_url = f"https://{request.url.netloc}" else: base_url = f"{request.url.scheme}://{request.url.netloc}" # Pass the email parameter to the frontend default_email = email or "" # Debug logging print(f"🔍 Chat widget called with email parameter: '{email}' -> defaultEmail: '{default_email}'") html_content = """ ChatCal.ai - Calendar Assistant

🌟 ChatCal.ai

Your friendly AI calendar assistant

👋 Welcome! I'm ChatCal, Peter Michael Gits' scheduling assistant.
I can schedule a meeting for you, just use the microphone button (đŸŽ™ī¸) next to the text input to speak and I will respond with both text and speech. To book a meeting, 1) say your name, 2) the date, time, length, and agenda. 3) GoogleMeet conference or phone call, and finally 4) your phone number, in case I need to call you if you forget.
ChatCal.ai v0.3.0 | ⚡ Streaming + Interruption | 📧 Smart Email Verification
""" return html_content.replace('{base_url}', base_url).replace('{default_email}', default_email) @router.get("/widget", response_class=HTMLResponse) async def embeddable_widget(): """Minimal embeddable widget for other websites.""" return """ """