Emalawi19 commited on
Commit
d640ea7
Β·
verified Β·
1 Parent(s): ff3a2a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -15,9 +15,9 @@ SECRET_KEY = os.environ.get("SECRET_KEY", "php-hosting-secret-key-change-
15
  ALGORITHM = "HS256"
16
  TOKEN_EXPIRE_MINS = 60 * 24 * 7
17
 
18
- MAX_FILE_BYTES = 25 * 1024 * 1024
19
- MAX_USER_BYTES = 500 * 1024 * 1024
20
- MAX_TOTAL_BYTES = 15 * 1024 * 1024 * 1024
21
 
22
  # ── Storage paths ─────────────────────────────────────────────────────────────
23
  DATA_DIR = Path("/data")
@@ -48,13 +48,13 @@ pwd_ctx = CryptContext(
48
 
49
  def hash_password(p: str) -> str:
50
  try:
51
- return pwd_ctx.hash(p)
52
  except Exception as e:
53
  raise HTTPException(500, f"Password hashing error: {e}")
54
 
55
  def verify_password(plain: str, hashed: str) -> bool:
56
  try:
57
- return pwd_ctx.verify(plain, hashed)
58
  except:
59
  return False
60
 
@@ -366,11 +366,11 @@ def storage_stats(user: dict = Depends(get_current_user)):
366
  user_used = get_dir_size(udir)
367
  total_used = get_total_storage()
368
  return {
369
- "user_used_mb": round(user_used / (1024 * 1024), 2),
370
- "user_limit_mb": 500,
371
- "total_used_gb": round(total_used / (1024 ** 3), 3),
372
- "total_limit_gb": 15,
373
- "percent_used": round((user_used / MAX_USER_BYTES) * 100, 2)
374
  }
375
  except HTTPException:
376
  raise
 
15
  ALGORITHM = "HS256"
16
  TOKEN_EXPIRE_MINS = 60 * 24 * 7
17
 
18
+ MAX_FILE_BYTES = 25 * 1024 * 1024
19
+ MAX_USER_BYTES = 500 * 1024 * 1024
20
+ MAX_TOTAL_BYTES = 15 * 1024 * 1024 * 1024
21
 
22
  # ── Storage paths ─────────────────────────────────────────────────────────────
23
  DATA_DIR = Path("/data")
 
48
 
49
  def hash_password(p: str) -> str:
50
  try:
51
+ return pwd_ctx.hash(p[:72])
52
  except Exception as e:
53
  raise HTTPException(500, f"Password hashing error: {e}")
54
 
55
  def verify_password(plain: str, hashed: str) -> bool:
56
  try:
57
+ return pwd_ctx.verify(plain[:72], hashed)
58
  except:
59
  return False
60
 
 
366
  user_used = get_dir_size(udir)
367
  total_used = get_total_storage()
368
  return {
369
+ "user_used_mb": round(user_used / (1024 * 1024), 2),
370
+ "user_limit_mb": 500,
371
+ "total_used_gb": round(total_used / (1024 ** 3), 3),
372
+ "total_limit_gb": 15,
373
+ "percent_used": round((user_used / MAX_USER_BYTES) * 100, 2)
374
  }
375
  except HTTPException:
376
  raise