我已经使用compojure
设置了一个最小的Web服务器,如下所示:
(defroutes m-routes
(GET "/index.html" []
{:status 200
:headers {"Content-Type" "text/html"}
:body (slurp "resources/index.html")})
(GET "/style.css" []
{:status 200
:headers {"Content-Type" "text/css"}
:body (slurp "resources/style.css")})
(GET "/index.js" []
{:status 200
:headers {"Content-Type" "application/javascript"}
:body (slurp "resources/index.js")})
(GET "*" []
"nothing here"))
index.html
:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=KEY&callback=mapReady">
</script>
<div id="toast"></div>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
如果尝试从浏览器访问它们,我可以GET
的所有资源文件,但是由于某些原因,主页index.html
并未加载它们。我可以说,因为没有样式应用于元素。控制台中没有错误。我应该如何使该服务器正常工作?