Spaces:
Running
Running
| #gradio_utils.py | |
| import gradio as gr # Still need this if type hinting gr.Request | |
| def get_url_user_token(request: gr.Request): | |
| """ | |
| This function is called when the Gradio app loads. | |
| It attempts to retrieve 'user_token' from the URL query parameters. | |
| """ | |
| user_token_from_url = "user_token not found in URL" # Default message | |
| if request: | |
| retrieved_token = request.query_params.get("session_id") | |
| org_urn = request.query_params.get("org_urn") | |
| if retrieved_token and org_urn: | |
| user_token_from_url = retrieved_token | |
| print(f"Retrieved user_token from URL: {user_token_from_url}") | |
| else: | |
| print(f"user_token key was not found in the URL query parameters.token {user_token_from_url}, urn {org_urn}") | |
| else: | |
| print("Request object not available to get_url_user_token function.") | |
| user_token_from_url = "Could not access request object on load" | |
| return user_token_from_url, org_urn | |
| # You could add other utility functions here in the future | |