(in-package #:hito) ;;; --- Server Configuration --- (defvar *app* nil "The Hunchentoot acceptor instance.") (defvar *port* 8080 "Port on which HITO listens.") (defvar *static-directory* (asdf:system-relative-pathname "hito" "static/") "Path to static assets (CSS, images).") ;;; --- Static File Serving --- (push (hunchentoot:create-folder-dispatcher-and-handler "/static/" *static-directory*) hunchentoot:*dispatch-table*) ;;; --- Server Lifecycle --- (defun start (&key (port *port*)) "Start the HITO web server. Initializes the database if needed." (when *app* (format t "~&Server already running on port ~D. Stop it first.~%" *port*) (return-from start nil)) ;; Ensure DB is ready (init-db) (setf *app* (make-instance 'hunchentoot:easy-acceptor :port port :document-root *static-directory*)) (hunchentoot:start *app*) (format t "~&HITO is running on port ~D.~%" port) *app*) (defun stop () "Stop the HITO web server." (when *app* (hunchentoot:stop *app*) (setf *app* nil) (format t "~&HITO stopped.~%") t))