init commit

This commit is contained in:
2025-07-14 18:32:55 +03:00
commit e54e57ca3d
25 changed files with 981 additions and 0 deletions

28
client/src/auth/login.py Normal file
View File

@ -0,0 +1,28 @@
from cryptography.fernet import Fernet
import os
import httpx
KEY_FILE = ".key"
REMEMBER_FILE = ".auth_data"
def generate_key():
if not os.path.exists(KEY_FILE):
key = Fernet.generate_key()
with open(KEY_FILE, "wb") as f:
f.write(key)
async def load_fernet():
with open(KEY_FILE, "rb") as f:
key = f.read()
return Fernet(key)
async def login(name: str, password: str):
async with httpx.AsyncClient() as client:
r = await client.post(f'http://127.0.0.1:7535/login?name={name}&password={password}')
if r.is_success:
return True
else:
return False