Update app.py
Browse files
app.py
CHANGED
@@ -107,11 +107,13 @@ async def update_dashboard(request: Request, userId: str, topic: str, year: str
|
|
107 |
# Return a redirect to the dash app
|
108 |
return RedirectResponse(url="/dash")
|
109 |
|
|
|
|
|
110 |
@app.get("/venue_redirect/{userId}/{topic}/{year}")
|
111 |
@app.get("/venue_redirect/{userId}/{topic}")
|
112 |
async def venue_redirect(request: Request, userId: str, topic: str, year: int = None):
|
113 |
"""
|
114 |
-
A centralized endpoint that redirects to the venue dashboard
|
115 |
"""
|
116 |
try:
|
117 |
# Reset the global venue_dash_app to ensure a fresh instance
|
@@ -122,12 +124,9 @@ async def venue_redirect(request: Request, userId: str, topic: str, year: int =
|
|
122 |
venue_dash_app = get_or_create_venue_dash_app()
|
123 |
app.mount("/venues", WSGIMiddleware(venue_dash_app.server))
|
124 |
|
125 |
-
|
126 |
-
base_url = f"{scheme}://{request.headers['host']}".rstrip('/')
|
127 |
dashboard_url = f"{base_url}/venues/"
|
128 |
-
|
129 |
-
# Don't attempt to open browser through backend when deployed
|
130 |
-
# This is the key change - let the frontend handle redirects instead
|
131 |
print(f"Redirecting to {dashboard_url}")
|
132 |
return RedirectResponse(url="/venues/")
|
133 |
except Exception as e:
|
|
|
107 |
# Return a redirect to the dash app
|
108 |
return RedirectResponse(url="/dash")
|
109 |
|
110 |
+
|
111 |
+
# Fix for venue_redirect endpoint
|
112 |
@app.get("/venue_redirect/{userId}/{topic}/{year}")
|
113 |
@app.get("/venue_redirect/{userId}/{topic}")
|
114 |
async def venue_redirect(request: Request, userId: str, topic: str, year: int = None):
|
115 |
"""
|
116 |
+
A centralized endpoint that redirects to the venue dashboard and opens it in a browser
|
117 |
"""
|
118 |
try:
|
119 |
# Reset the global venue_dash_app to ensure a fresh instance
|
|
|
124 |
venue_dash_app = get_or_create_venue_dash_app()
|
125 |
app.mount("/venues", WSGIMiddleware(venue_dash_app.server))
|
126 |
|
127 |
+
base_url = str(request.base_url).rstrip('/')
|
|
|
128 |
dashboard_url = f"{base_url}/venues/"
|
129 |
+
open_browser_safely(dashboard_url)
|
|
|
|
|
130 |
print(f"Redirecting to {dashboard_url}")
|
131 |
return RedirectResponse(url="/venues/")
|
132 |
except Exception as e:
|