Spaces:
Paused
Paused
Commit
•
6d8e1bf
1
Parent(s):
3b22eeb
Update imports in main.py
Browse files
main.py
CHANGED
@@ -6,10 +6,10 @@ from datetime import datetime
|
|
6 |
from pathlib import Path
|
7 |
|
8 |
from dotenv import load_dotenv
|
9 |
-
from fastapi import BackgroundTasks, FastAPI, Header
|
10 |
from fastapi.middleware.cors import CORSMiddleware
|
11 |
from huggingface_hub import CommitScheduler, HfApi, whoami
|
12 |
-
from huggingface_hub.utils import HTTPError
|
13 |
from pydantic import BaseModel
|
14 |
from starlette.responses import RedirectResponse
|
15 |
|
@@ -75,7 +75,7 @@ class Vote(BaseModel):
|
|
75 |
|
76 |
def validate_token(token: str):
|
77 |
try:
|
78 |
-
|
79 |
return True
|
80 |
except HTTPError as e:
|
81 |
# check for HTTPError: Invalid user token. If you didn't pass a user token, make sure you are properly logged in by executing `huggingface-cli login`, and if you did pass a user token, double-check it's correct. in the error message
|
|
|
6 |
from pathlib import Path
|
7 |
|
8 |
from dotenv import load_dotenv
|
9 |
+
from fastapi import BackgroundTasks, FastAPI, Header
|
10 |
from fastapi.middleware.cors import CORSMiddleware
|
11 |
from huggingface_hub import CommitScheduler, HfApi, whoami
|
12 |
+
from huggingface_hub.utils._errors import HTTPError
|
13 |
from pydantic import BaseModel
|
14 |
from starlette.responses import RedirectResponse
|
15 |
|
|
|
75 |
|
76 |
def validate_token(token: str):
|
77 |
try:
|
78 |
+
whoami(token=token)
|
79 |
return True
|
80 |
except HTTPError as e:
|
81 |
# check for HTTPError: Invalid user token. If you didn't pass a user token, make sure you are properly logged in by executing `huggingface-cli login`, and if you did pass a user token, double-check it's correct. in the error message
|