diff --git a/solara/lib/core/dashboard/dashboard_server.rb b/solara/lib/core/dashboard/dashboard_server.rb index c1095da..9481423 100644 --- a/solara/lib/core/dashboard/dashboard_server.rb +++ b/solara/lib/core/dashboard/dashboard_server.rb @@ -47,9 +47,23 @@ def create_server @server = WEBrick::HTTPServer.new( Port: @port, DocumentRoot: @root, - DirectoryIndex: ['index.html'], Logger: logger ) + + @server.mount_proc '/' do |req, res| + path = req.path == '/' ? '/index.html' : req.path + file_path = File.join(@root, path) + + if File.exist?(file_path) && !File.directory?(file_path) + res.body = File.read(file_path) + res['Content-Type'] = WEBrick::HTTPUtils.mime_type(file_path, WEBrick::HTTPUtils::DefaultMimeTypes) + else + res.status = 404 + end + + # Add the source=local parameter to all responses + res['Location'] = "#{req.path}?source=local" if res.status == 302 + end rescue StandardError => e Solara.logger.failure("Error creating server: #{e.message}") exit(1) diff --git a/solara/lib/core/dashboard/index.html b/solara/lib/core/dashboard/index.html index 14393bc..c709d5b 100644 --- a/solara/lib/core/dashboard/index.html +++ b/solara/lib/core/dashboard/index.html @@ -1,41 +1,58 @@ - - - - Redirecting... - - - - -
- Logo Image -
- + } else { + console.error('Invalid source parameter'); + } + + + +
+ Logo Image +
+ \ No newline at end of file