commit 6d2fe5a50701904ce6c1e74dcc6b5e228af61c92
parent c4fa07f69a4ca8de26b18e5509463fc72e47f71d
Author: Andrew Laack <andrew@laack.co>
Date: Tue, 1 Sep 2026 20:45:55 -0500
Robots.txt
Diffstat:
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/learning/bin/main.ml b/learning/bin/main.ml
@@ -1,6 +1,6 @@
open Learning
-(*TODO: Make this a whitelist based on the page / course lists*)
+(* TODO: Make this a whitelist based on the page / course lists *)
let is_safe_path name =
String.length name > 0
@@ -10,7 +10,6 @@ let is_safe_path name =
(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|| (c >= '0' && c <= '9') || c = '-' || c = '_' || c = '.') name
-
(* TODO: Ensure server responds correctly to invalid requests. *)
(*
Examples: Non-existent course
@@ -19,13 +18,12 @@ let is_safe_path name =
Examples: Unknown path
*)
-
let my_error_template _error debug_info suggested_response =
let status = Dream.status suggested_response in
let code = Dream.status_to_int status
and reason = Dream.status_to_string status in
Dream.set_header suggested_response "Content-Type" Dream.text_html;
- Dream.set_body suggested_response ((string_of_int code) ^ " - " ^ reason);
+ Dream.set_body suggested_response ("<h1>" ^ (string_of_int code) ^ " - " ^ reason ^ "</h1>");
Lwt.return suggested_response
@@ -43,6 +41,7 @@ let () =
Dream.get "/static/**" (Dream.static "./static");
Dream.get "/" (fun _ -> Dream.html (Render.render_sidebar @@ Render.render_course_list));
+ Dream.get "/robots.txt" (Dream.from_filesystem "./static" "robots.txt");
Dream.get "/course/:course_name/page/assets/**" (fun request -> Dream.static
(Shared.course_dir ^
diff --git a/learning/static/robots.txt b/learning/static/robots.txt
@@ -0,0 +1,2 @@
+User-agent: *
+Disallow: