fix(): Ajuste arquivo main.py, aplicado rota estática para visualização de arquivos
This commit is contained in:
parent
7afa41c710
commit
7811d8e18e
1 changed files with 34 additions and 0 deletions
34
main.py
34
main.py
|
|
@ -48,6 +48,40 @@ app.mount(
|
||||||
name="storage_access",
|
name="storage_access",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# main.py (adicione abaixo do app.mount)
|
||||||
|
|
||||||
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
|
|
||||||
|
# [INÍCIO DO NOVO CÓDIGO DE DIAGNÓSTICO]
|
||||||
|
@app.get(
|
||||||
|
"/api/v1/storage-check"
|
||||||
|
) # Note o prefixo /api/v1 (ou ajuste se o seu config.url for outro)
|
||||||
|
def check_storage_path():
|
||||||
|
storage_path = "/app/storage"
|
||||||
|
|
||||||
|
response_data = {
|
||||||
|
"diretorio_montado": storage_path,
|
||||||
|
"diretorio_existe": os.path.isdir(storage_path),
|
||||||
|
"arquivo_alvo_existe": os.path.exists(
|
||||||
|
os.path.join(storage_path, "Grantfile_jbpdy8ex.pdf")
|
||||||
|
),
|
||||||
|
"arquivos_encontrados": [],
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Tenta listar o conteúdo da pasta
|
||||||
|
response_data["arquivos_encontrados"] = os.listdir(storage_path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
response_data["erro_listdir"] = "Diretório não encontrado pelo Python"
|
||||||
|
except Exception as e:
|
||||||
|
response_data["erro_listdir"] = f"Erro de permissão ou outro: {e}"
|
||||||
|
|
||||||
|
return JSONResponse(response_data)
|
||||||
|
|
||||||
|
|
||||||
|
# [FIM DO NOVO CÓDIGO DE DIAGNÓSTICO]
|
||||||
|
|
||||||
# Adiciona o middleware global de erro
|
# Adiciona o middleware global de erro
|
||||||
# app.middleware("http")(database_error_handler)
|
# app.middleware("http")(database_error_handler)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue