Spaces:
Runtime error
Runtime error
Download auth/create_token.py from subhandev1/webmentai: direct link, hf CLI and curl.
- Browser
- Download file 479 Bytes
-
https://huggingface.co/spaces/subhandev1/webmentai/resolve/main/auth/create_token.py
- Command line
-
hf download hf://spaces/subhandev1/webmentai/auth/create_token.py
-
curl -L -o create_token.py https://huggingface.co/spaces/subhandev1/webmentai/resolve/main/auth/create_token.py
479 Bytes
| from datetime import datetime, timedelta | |
| from jose import jwt | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| SECRET_KEY = os.getenv("SECRET_KEY") | |
| ALGORITHM = os.getenv("ALGORITHM") | |
| def create_access_token(data: dict, expires_delta: timedelta | None = None): | |
| to_encode = data.copy() | |
| expire = datetime.utcnow() + (expires_delta or timedelta(minutes=60)) | |
| to_encode.update({"exp": expire}) | |
| return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM) | |