-httpserver.new{ port = 5280, base = "files", handler = handle_request, ssl = false}
\ No newline at end of file
+local function handle_file_request(method, body, request)
+ local path = preprocess_path(request.url.path);
+ if not path then return response_400; end
+ path = path:gsub("^/[^/]+", ""); -- Strip /files/
+ return serve_file(path);
+end
+
+local function handle_default_request(method, body, request)
+ local path = preprocess_path(request.url.path);
+ if not path then return response_400; end
+ return serve_file(path);
+end
+
+local ports = config.get(module.host, "core", "http_ports") or { 5280 };
+httpserver.set_default_handler(handle_default_request);
+httpserver.new_from_config(ports, handle_file_request, { base = "files" });