provide fallback image

return fallback image if image is not found @imgserver
This commit is contained in:
geoffrey45
2022-06-20 13:00:59 +03:00
parent 12c8406a0d
commit 84880f8cad
3 changed files with 56 additions and 12 deletions
+34
View File
@@ -2,10 +2,42 @@
Contains the functions to prepare the server for use.
"""
import os
import shutil
from app import settings
class CopyFiles:
"""Copies assets to the app directory."""
def __init__(self) -> None:
files = [
{
"src": "assets",
"dest": os.path.join(settings.APP_DIR, "assets"),
"is_dir": True,
}
]
for entry in files:
src = os.path.join(os.getcwd(), entry["src"])
print(f"Copying {src} to {entry['dest']}")
if entry["is_dir"]:
shutil.copytree(
src,
entry["dest"],
ignore=shutil.ignore_patterns(
"*.pyc",
),
copy_function=shutil.copy2,
dirs_exist_ok=True,
)
break
shutil.copy2(src, entry["dest"])
def create_config_dir() -> None:
"""
Creates the config directory if it doesn't exist.
@@ -29,3 +61,5 @@ def create_config_dir() -> None:
if not exists:
os.makedirs(path)
os.chmod(path, 0o755)
CopyFiles()