Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,32 +6,11 @@ from Data_Fetching_and_Rendering import fetch_and_render_dashboard
|
|
6 |
from analytics_fetch_and_rendering import fetch_and_render_analytics
|
7 |
from mentions_dashboard import generate_mentions_dashboard
|
8 |
|
|
|
|
|
9 |
# Shared state for token received via POST
|
10 |
token_received = {"status": False, "token": None, "client_id": None}
|
11 |
|
12 |
-
# --- Function to get user_token from URL on load ---
|
13 |
-
def get_url_user_token(request: gr.Request):
|
14 |
-
"""
|
15 |
-
This function is called when the Gradio app loads.
|
16 |
-
It attempts to retrieve 'user_token' from the URL query parameters.
|
17 |
-
"""
|
18 |
-
user_token_from_url = "user_token not found in URL" # Default message
|
19 |
-
if request:
|
20 |
-
# request.query_params is a dictionary-like object.
|
21 |
-
# Example URL: https://your-gradio-app/?user_token=ABC123XYZ
|
22 |
-
# query_params would be {'user_token': 'ABC123XYZ'}
|
23 |
-
retrieved_token = request.query_params.get("session_id")
|
24 |
-
if retrieved_token:
|
25 |
-
user_token_from_url = retrieved_token
|
26 |
-
print(f"Retrieved user_token from URL: {user_token_from_url}")
|
27 |
-
else:
|
28 |
-
print("user_token key was not found in the URL query parameters.")
|
29 |
-
else:
|
30 |
-
# This case should ideally not happen if app.load is configured correctly
|
31 |
-
# and Gradio supplies the request object.
|
32 |
-
print("Request object not available to get_url_user_token function.")
|
33 |
-
user_token_from_url = "Could not access request object on load"
|
34 |
-
return user_token_from_url
|
35 |
|
36 |
# --- Handlers for token reception (POST) and status ---
|
37 |
def receive_token(accessToken: str, client_id: str):
|
|
|
6 |
from analytics_fetch_and_rendering import fetch_and_render_analytics
|
7 |
from mentions_dashboard import generate_mentions_dashboard
|
8 |
|
9 |
+
from gradio_utils import get_url_user_token
|
10 |
+
|
11 |
# Shared state for token received via POST
|
12 |
token_received = {"status": False, "token": None, "client_id": None}
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# --- Handlers for token reception (POST) and status ---
|
16 |
def receive_token(accessToken: str, client_id: str):
|