https and ssl integration on the backend, frontend and started integration of logistics app as a separate frontend
This commit is contained in:
@ -1,6 +1,4 @@
|
||||
import os
|
||||
import tempfile # <-- Add this import
|
||||
import xml.etree.ElementTree as ET
|
||||
import os, tempfile, time, random, hashlib
|
||||
from fastapi import APIRouter, HTTPException, status, Depends, Response
|
||||
from sqlalchemy.orm import Session, joinedload
|
||||
from typing import List
|
||||
@ -38,9 +36,12 @@ from app.crud import get_shipments, get_shipment_by_id # Import CRUD functions
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
def generate_unique_id(db: Session) -> str:
|
||||
def generate_unique_id(db: Session, length: int = 16) -> str:
|
||||
while True:
|
||||
unique_id = str(uuid.uuid4())
|
||||
base_string = f"{time.time()}{random.randint(0, 10 ** 6)}"
|
||||
hash_object = hashlib.sha256(base_string.encode())
|
||||
hash_digest = hash_object.hexdigest()
|
||||
unique_id = ''.join(random.choices(hash_digest, k=length))
|
||||
existing_dewar = db.query(DewarModel).filter(DewarModel.unique_id == unique_id).first()
|
||||
if not existing_dewar:
|
||||
break
|
||||
|
Reference in New Issue
Block a user