PhotosAPI/photos_api.py

44 lines
1.1 KiB
Python
Raw Normal View History

2023-06-23 12:25:27 +03:00
import logging
2023-11-25 19:05:12 +02:00
from argparse import ArgumentParser
2023-06-23 11:51:42 +03:00
from os import makedirs
from pathlib import Path
2023-06-22 14:17:53 +03:00
from fastapi.responses import FileResponse
2022-12-20 02:22:32 +02:00
from modules.app import app
from modules.extensions_loader import dynamic_import_from_src
2023-11-25 19:05:12 +02:00
from modules.migrator import migrate_database
2023-06-22 14:17:53 +03:00
from modules.scheduler import scheduler
2022-12-20 02:22:32 +02:00
2023-06-23 11:51:42 +03:00
makedirs(Path("data/users"), exist_ok=True)
2022-12-20 02:22:32 +02:00
2023-06-23 12:25:27 +03:00
logging.basicConfig(
level=logging.INFO,
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
datefmt="[%X]",
)
2022-12-20 02:22:32 +02:00
@app.get("/favicon.ico", response_class=FileResponse, include_in_schema=False)
async def favicon():
return FileResponse("favicon.ico")
2023-03-12 15:59:13 +02:00
# =================================================================================
dynamic_import_from_src("extensions", star_import=True)
# =================================================================================
2022-12-20 23:24:46 +02:00
2023-03-12 15:59:13 +02:00
scheduler.start()
2023-11-25 19:05:12 +02:00
parser = ArgumentParser(
prog="PhotosAPI",
description="Small and simple API server for saving photos and videos.",
)
parser.add_argument("--migrate", action="store_true")
2023-11-25 19:14:30 +02:00
args, unknown = parser.parse_known_args()
2023-11-25 19:05:12 +02:00
if args.migrate:
migrate_database()