Spaces:
Paused
Paused
Commit
•
88c2e3b
1
Parent(s):
c892caa
Add FastAPI import and update unauthorized response
Browse files
main.py
CHANGED
@@ -12,6 +12,7 @@ from huggingface_hub import CommitScheduler, HfApi, whoami
|
|
12 |
from huggingface_hub.utils._errors import HTTPError
|
13 |
from pydantic import BaseModel, Field
|
14 |
from starlette.responses import RedirectResponse
|
|
|
15 |
|
16 |
load_dotenv()
|
17 |
|
@@ -89,8 +90,10 @@ async def receive_vote(
|
|
89 |
):
|
90 |
token = authorization.split(" ")[1]
|
91 |
if not validate_token(token):
|
92 |
-
|
93 |
-
|
|
|
|
|
94 |
vote_entry = {
|
95 |
"dataset": vote.dataset,
|
96 |
"vote": vote.vote,
|
|
|
12 |
from huggingface_hub.utils._errors import HTTPError
|
13 |
from pydantic import BaseModel, Field
|
14 |
from starlette.responses import RedirectResponse
|
15 |
+
from fastapi import FastAPI, HTTPException, status
|
16 |
|
17 |
load_dotenv()
|
18 |
|
|
|
90 |
):
|
91 |
token = authorization.split(" ")[1]
|
92 |
if not validate_token(token):
|
93 |
+
raise HTTPException(
|
94 |
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
95 |
+
detail="Invalid user token.",
|
96 |
+
)
|
97 |
vote_entry = {
|
98 |
"dataset": vote.dataset,
|
99 |
"vote": vote.vote,
|