Spaces:
Sleeping
Sleeping
Download storage.py from Mangesh223/SecureAuthentication: direct link, hf CLI and curl.
- Browser
- Download file 520 Bytes
-
https://huggingface.co/spaces/Mangesh223/SecureAuthentication/resolve/main/storage.py
- Command line
-
hf download hf://spaces/Mangesh223/SecureAuthentication/storage.py
-
curl -L -o storage.py https://huggingface.co/spaces/Mangesh223/SecureAuthentication/resolve/main/storage.py
520 Bytes
| import json | |
| import os | |
| from pathlib import Path | |
| DATA_FILE = "users.json" | |
| def load_users(): | |
| if not Path(DATA_FILE).exists(): | |
| return {} | |
| with open(DATA_FILE, "r") as f: | |
| return json.load(f) | |
| def save_users(users): | |
| with open(DATA_FILE, "w") as f: | |
| json.dump(users, f) | |
| def add_user(username, hashed_password): | |
| users = load_users() | |
| users[username] = {"password": hashed_password} | |
| save_users(users) | |
| def get_user(username): | |
| users = load_users() | |
| return users.get(username) |