Spaces:
Sleeping
Sleeping
File size: 520 Bytes
805f8a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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) |