Basically wrote the whole thing.
This commit is contained in:
28
server.py
Normal file
28
server.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""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()
|
||||
Reference in New Issue
Block a user