Spaces:
Running
Running
new check for token2
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ from author_leaderboard_tab import author_leaderboard_tab
|
|
7 |
from pr_paper_central_tab import pr_paper_central_tab
|
8 |
from huggingface_hub import whoami
|
9 |
import json
|
|
|
10 |
|
11 |
from author_leaderboard_contrib_tab import author_resource_leaderboard_tab
|
12 |
from zoneinfo import ZoneInfo # Available in Python 3.9 and later
|
@@ -16,15 +17,23 @@ paper_central_df = PaperCentral()
|
|
16 |
|
17 |
|
18 |
def hide_if_logged_in(oauth_token: Optional[gr.OAuthToken]):
|
19 |
-
if oauth_token is None
|
|
|
|
|
|
|
|
|
|
|
20 |
return gr.update(visible=True)
|
21 |
-
return gr.update(visible=False)
|
22 |
|
23 |
|
24 |
def display_user_info(oauth_token: Optional[gr.OAuthToken]):
|
25 |
-
if oauth_token is None
|
|
|
|
|
|
|
|
|
|
|
26 |
return ""
|
27 |
-
user_info = whoami(oauth_token.token)
|
28 |
avatar_url = user_info.get("avatarUrl", "")
|
29 |
fullname = user_info.get("fullname", "")
|
30 |
name = user_info.get("name", "")
|
|
|
7 |
from pr_paper_central_tab import pr_paper_central_tab
|
8 |
from huggingface_hub import whoami
|
9 |
import json
|
10 |
+
import requests
|
11 |
|
12 |
from author_leaderboard_contrib_tab import author_resource_leaderboard_tab
|
13 |
from zoneinfo import ZoneInfo # Available in Python 3.9 and later
|
|
|
17 |
|
18 |
|
19 |
def hide_if_logged_in(oauth_token: Optional[gr.OAuthToken]):
|
20 |
+
if oauth_token is None:
|
21 |
+
return gr.update(visible=True)
|
22 |
+
try:
|
23 |
+
whoami(oauth_token.token)
|
24 |
+
return gr.update(visible=False)
|
25 |
+
except requests.exceptions.HTTPError as e:
|
26 |
return gr.update(visible=True)
|
|
|
27 |
|
28 |
|
29 |
def display_user_info(oauth_token: Optional[gr.OAuthToken]):
|
30 |
+
if oauth_token is None:
|
31 |
+
return ""
|
32 |
+
try:
|
33 |
+
user_info = whoami(oauth_token.token)
|
34 |
+
except requests.exceptions.HTTPError as e:
|
35 |
+
print(e)
|
36 |
return ""
|
|
|
37 |
avatar_url = user_info.get("avatarUrl", "")
|
38 |
fullname = user_info.get("fullname", "")
|
39 |
name = user_info.get("name", "")
|