-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcipher.py
More file actions
31 lines (27 loc) · 963 Bytes
/
cipher.py
File metadata and controls
31 lines (27 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from sqlalchemy.orm import Session
from fastapi import APIRouter, Depends, Query
from services.process_service import encrypt_uploaded_file, decrypt_uploaded_file, get_task_status
from db.session import get_db
router = APIRouter()
@router.post("/encrypt")
def encrypt_file_route(
file_path: str,
shift: int,
token: str = Query(None),
db: Session = Depends(get_db)
):
"""Route to encrypt a file using Caesar cipher."""
return encrypt_uploaded_file(file_path, shift, token, db)
@router.post("/decrypt")
def decrypt_file_route(
file_path: str,
shift: int,
token: str = Query(None),
db: Session = Depends(get_db)
):
"""Route to decrypt a file using Caesar cipher."""
return decrypt_uploaded_file(file_path, shift, token, db)
@router.get("/status/{task_id}")
def get_task_status_route(task_id: str, db: Session = Depends(get_db)):
"""Route to get the status of a task."""
return get_task_status(task_id, db)