404 GET / Когда доступен index.html
Я пытаюсь написать простой статический сайт на Crystal, используя Kemal.
Переходя на эту страницу, я должен быть в порядке, но я получаю 404, когда я пытаюсь загрузить сайт.
Моя программа выглядит так (вы можете увидеть весь код, который я закомментировал, пытаясь отследить проблему)
#require "./LiedThisWeek/*"
require "kemal"
#module LiedThisWeek
# TODO Put your code here
#end
#finder = LieFinder.new
#handler = HyperTextHandler.new finder
#indexPath = "public/index.html"
#
#spawn do
# loop do
# finder.refresh
# File.write indexPath, handler.getDoc
# sleep 60.second
# end
#end
Kemal.run
Вот как выглядит моя структура каталогов:
.
├── LICENSE
├── LiedThisWeek
├── README.md
├── lib (removed for brevity)
├── public
│ ├── css
│ │ └── style.css
│ ├── images
│ │ ├── fireworks.jpg
│ │ └── sad.jpg
│ └── index.html
├── shard.lock
├── shard.yml
├── spec
│ ├── LiedThisWeek_spec.cr
│ └── spec_helper.cr
└── src
├── LiedThisWeek
│ ├── HyperTextHandler.cr
│ ├── Lie.cr
│ ├── LieFinder.cr
│ └── version.cr
└── LiedThisWeek.cr
32 directories, 112 files
1 ответ
Решение
Автор Кемаль здесь.
Кемаль не служит index.html
как /
по умолчанию. Однако вы можете достичь этого с redirect
get "/" do |env|
env.redirect "index.html"
end