Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified __pycache__/database.cpython-312.pyc
Binary file not shown.
12 changes: 10 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def login(user: UserLogin):
username, password_hash = user_data
if verify_password(user.password, password_hash):
return {"message": "Login successful"}
raise HTTPException(status_code=401, detail="Invalid username or password")
raise HTTPException(status_code=401, detail="Napaka")

# API endpoint za registracijo
@app.post("/register/")
Expand Down Expand Up @@ -100,7 +100,15 @@ async def read_notes(request: Request):
username = request.query_params.get("username")
conn = get_db_conn()
cursor = conn.cursor()
cursor.execute('SELECT * FROM notes ORDER BY id DESC')
cursor.execute('''
SELECT notes.*, users.username
FROM notes
JOIN users ON notes.user_id = users.id
WHERE users.username = ?
ORDER BY notes.id DESC
''', (username,))


notes = cursor.fetchall()
conn.close()

Expand Down