mirror of
https://github.com/Rainyy21/Front-end-Design-Project.git
synced 2026-10-10 23:40:24 -04:00
search_bar been added
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user