"""Minimal entry-point for the SWIPER web-server.

   Usage:  python server.py
"""
from http.server import HTTPServer

from config import DB_PATH, IMAGE_DIR, PORT
from database import init_db, sync_image_database
from handler import ImageSwipeHandler


def run(port: int = PORT) -> None:  # noqa: D401
    """Start the HTTP server on the given port."""
    init_db()
    sync_image_database()

    server_address = ("", port)
    httpd = HTTPServer(server_address, ImageSwipeHandler)

    print(f"Starting server on port {port}…")
    print(f"Image directory: {IMAGE_DIR}")
    print(f"Database: {DB_PATH}")

    httpd.serve_forever()


if __name__ == "__main__":
    run()
