Serving static files with Kemal (I filed the issue on the Kemal GitHub repo, but got no answer, so I'm reposting my question here)

Description

  • Problem serving local files.
  • I tried the code hereunder, but the local file do not seem to be served.
  • Perhaps my minimalist server is missing an instruction linking the local files to a given route ?

Steps to Reproduce

  1. Code for the server
require "kemal"

IP = "127.0.0.1"
PORT = 8081

Kemal.config.port = (ENV["PORT"]? || PORT).to_i
Kemal.config.host_binding = ENV["HOST_BINDING"]? || "#{IP}"
# Kemal.config.env = "production"

Kemal.run do |config|
  config.public_folder = "dist"
end
  1. Compile and run 1.

Expected behavior:
I would expect that when te browser points to http://127.0.0.1:8081/ or http://127.0.0.1:8081/index.html, the content of said index.html page is displayed in the browser.

Actual behavior: Instead, I get:

Hi @serge-hulne

You can use the following to achieve what you want.

public_folder "dist"

Kemal.run

IDK why but the config block does not work as intended.

2 Likes

Thank you.

1 Like