Skip to content

removed unused libraries from server #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2024
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
17 changes: 4 additions & 13 deletions server/db/category_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys
from pathlib import Path
from shutil import copyfile
from urllib.parse import urlparse
Expand All @@ -8,15 +7,6 @@
categories_folder = Path('./uploads/categories')

def get_filename_from_url(url):
"""
Extracts the filename from a URL after the '/uploads/' part.

Args:
url (str): The full URL.

Returns:
str: The filename part of the URL.
"""
# Parse the URL
parsed_url = urlparse(url)

Expand Down Expand Up @@ -50,7 +40,7 @@ def create_categories(labels):
def add_image_folder(label, image_name, image_src):
image_src = get_filename_from_url(image_src)
image_name = os.path.splitext(image_src)
print(f"Adding image {image_name} to category {label} with base name {image_src}")
print(f"adding image {image_name} to category {label} with base name {image_src}")
base_name = os.path.basename(image_src)
try:
if image_name not in os.listdir(categories_folder / label):
Expand All @@ -70,6 +60,7 @@ def remove_image_folder(label, image_name):
try:
if image_name in os.listdir(categories_folder / label):
os.remove(categories_folder / label / image_name)
except:
print('nothing there')
except Exception as e:
print('error in removing image ' + image_name + ' from category ' + label)
print('Error:', e)
return
1 change: 0 additions & 1 deletion server/db/db_handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import pandas as pd
import numpy as np
import uuid
from db.category_handler import create_categories, remove_image_folder, add_image_folder

Expand Down
2 changes: 0 additions & 2 deletions server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
flask
flask-cors
numpy
pandas
python-dotenv
pillow
requests
Loading