13ze commited on
Commit
03b3462
·
verified ·
1 Parent(s): 8afd771

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -5,12 +5,12 @@ import re
5
  from PIL import Image
6
 
7
  # Diretório onde os arquivos serão armazenados
8
- STORAGE_DIR = "/home/user/storage"
9
  ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'webp'}
10
  MAX_FILE_SIZE = 10 * 1024 * 1024 # 10MB
11
 
12
  # Nome do espaço HuggingFace
13
- SPACE_NAME = os.getenv('SPACE_NAME')
14
 
15
  # Função para inicializar o diretório de armazenamento
16
  def initialize_storage():
@@ -66,7 +66,7 @@ def upload_file(file):
66
  # Função para deletar o arquivo
67
  def delete_file(file_name):
68
  file_path = os.path.join(STORAGE_DIR, file_name)
69
- if os.path.exists(file_path):
70
  os.remove(file_path)
71
  return f"Arquivo {file_name} deletado com sucesso."
72
  return f"Arquivo {file_name} não encontrado."
 
5
  from PIL import Image
6
 
7
  # Diretório onde os arquivos serão armazenados
8
+ STORAGE_DIR = "storage"
9
  ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'webp'}
10
  MAX_FILE_SIZE = 10 * 1024 * 1024 # 10MB
11
 
12
  # Nome do espaço HuggingFace
13
+ SPACE_NAME = os.getenv('SPACE_NAME', '13ze/cloud-storage')
14
 
15
  # Função para inicializar o diretório de armazenamento
16
  def initialize_storage():
 
66
  # Função para deletar o arquivo
67
  def delete_file(file_name):
68
  file_path = os.path.join(STORAGE_DIR, file_name)
69
+ if os.path.isfile(file_path):
70
  os.remove(file_path)
71
  return f"Arquivo {file_name} deletado com sucesso."
72
  return f"Arquivo {file_name} não encontrado."