search_bar been added

This commit is contained in:
Rainy21
2026-02-26 12:25:59 -05:00
parent 69e2ee8258
commit 4e17c2df8c
6 changed files with 75 additions and 7 deletions
+23
View File
@@ -67,6 +67,29 @@ def add_media():
conn.close()
return redirect(url_for('index'))
@app.route('/delete/<int:media_id>',methods=['POST'])
def delete_media(media_id):
conn = sqlite3.connect(DB_NAME)
cursor = conn.cursor()
cursor.execute("SELECT image_path FROM media WHERE id = ?",(media_id,))
row = cursor.fetchone()
if row and row[0] != 'default.jpg':
image_path = os.path.join(UPLOAD_FOLDER, row[0])
if os.path.exists(image_path):
os.remove(image_path)
cursor.execute("DELETE from media WHERE id = ?",(media_id,))
cursor.execute("DELETE from books WHERE book_id = ?",(media_id,))
cursor.execute("DELETE from shows WHERE show_id = ?",(media_id,))
cursor.execute("DELETE from media_genres WHERE media_id = ?",(media_id,))
conn.commit()
cursor.close()
conn.close()
return redirect(url_for('index'))
if __name__ == '__main__':
init_db()
app.run(debug=True)