I'm trying to learn Crystal. As an exercise, I'm making a simple web application, which needs to serve a file (called index.html
).
Unfortunately, I can only figure out how to serve the directory the file resides in. This is hat you get if you load up http://localhost:
Directory listing for /
index.html
style.css
But I of course want to see the contents of index.html instead.
My code is as follows:
require "http/server"
port = 3000
server = HTTP::Server.new("127.0.0.1", port, [
HTTP::ErrorHandler.new,
HTTP::LogHandler.new,
HTTP::CompressHandler.new,
HTTP::StaticFileHandler.new("./assets"),
])
puts "listening on http://localhost:#{port}"
server.listen