Spaces:
Running
Running
Download scripts/seed_admin.py from bevisssssss/driver: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/spaces/bevisssssss/driver/resolve/main/scripts/seed_admin.py
- Command line
-
hf download hf://spaces/bevisssssss/driver/scripts/seed_admin.py
-
curl -L -o seed_admin.py https://huggingface.co/spaces/bevisssssss/driver/resolve/main/scripts/seed_admin.py
710 Bytes
| """Create or update the initial admin account.""" | |
| import sys | |
| import os | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) | |
| from server.db import init_db, create_admin, get_admin | |
| from server.auth import hash_password | |
| def main(): | |
| init_db() | |
| username = os.getenv("ADMIN_USER", "admin") | |
| password = os.getenv("ADMIN_PASS", "admin123") | |
| if get_admin(username): | |
| print(f"Admin '{username}' already exists, skipping.") | |
| return | |
| pw_hash = hash_password(password) | |
| if create_admin(username, pw_hash): | |
| print(f"Admin '{username}' created successfully.") | |
| else: | |
| print(f"Failed to create admin '{username}'.") | |
| if __name__ == "__main__": | |
| main() | |