"""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 = """ VoiceCal.ai - Calendar Assistant

🌟 VoiceCal.ai

Your friendly AI calendar assistant

👋 Welcome! I'm VoiceCal, Peter Michael Gits' scheduling assistant.
Just speak into your microphone.

To book a meeting:

1) Say your name

2) The date, time, length, and agenda

3) GoogleMeet conference or phone call

4) Your phone number, in case I need to call you

VoiceCal.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 """ """