From ebd0fcc44895dfff8e4e1d1bc0cb1c31b236ae57 Mon Sep 17 00:00:00 2001 From: Ole-Morten Duesund Date: Sat, 27 Sep 2025 16:47:29 +0200 Subject: [PATCH] Redesign main page with minimalist "No" and move interactive UI to /playground MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create elegant minimalist main page with centered "No" - Add automatic dark mode support for main page - Move original interactive API testing interface to /playground - Add footer links to main page for navigation - Update routing to serve both pages appropriately - Update documentation to reflect new page structure The main page now provides a clean, focused experience while the playground remains available for API testing and exploration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CLAUDE.md | 7 ++-- README.md | 3 +- src/main.rs | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 98 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 2593432..5cebe03 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -56,10 +56,13 @@ The entire application is contained in `src/main.rs` with ~372 lines of code. Th ### Key Components -1. **Embedded HTML Frontend**: The HTML/CSS/JavaScript frontend is embedded as a string constant (`HTML_FRONTEND`) directly in the source code, eliminating the need for static file serving. +1. **Embedded HTML Frontends**: Two HTML frontends are embedded as string constants: + - `SIMPLE_FRONTEND`: Minimalist main page with just "No" centered on screen + - `PLAYGROUND_FRONTEND`: Interactive API testing playground with buttons and examples 2. **Request Router**: The `route_request()` function handles all routing logic: - - `/` - Serves the embedded HTML frontend + - `/` - Serves the minimalist "No" page + - `/playground` - Serves the interactive API testing interface - `/api/no` - API endpoint with format parameter support - `/health` - Health check endpoint - CORS headers are added to all responses diff --git a/README.md b/README.md index 27db3da..072c14b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ A lightweight, production-ready HTTP service that always says "no" in various fo ## API Endpoints -- `GET /` - Web frontend +- `GET /` - Minimalist web page displaying "No" +- `GET /playground` - Interactive API testing playground - `GET /api/no` - Returns plain text "no" - `GET /api/no?format=json` - Returns `{"answer": "no"}` - `GET /api/no?format=bool` - Returns `false` diff --git a/src/main.rs b/src/main.rs index 8ff749a..7523540 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,95 @@ use std::io::prelude::*; use std::net::{TcpListener, TcpStream}; use std::thread; -const HTML_FRONTEND: &str = r#" +const SIMPLE_FRONTEND: &str = r#" + + + + + No + + + +
No
+ + +"#; + +const PLAYGROUND_FRONTEND: &str = r#" @@ -315,7 +403,8 @@ fn route_request(request_line: &str) -> (&str, &str, String) { } match path { - "/" => ("200 OK", "text/html; charset=utf-8", HTML_FRONTEND.to_string()), + "/" => ("200 OK", "text/html; charset=utf-8", SIMPLE_FRONTEND.to_string()), + "/playground" => ("200 OK", "text/html; charset=utf-8", PLAYGROUND_FRONTEND.to_string()), "/health" => ("200 OK", "text/plain", "OK".to_string()), path if path.starts_with("/api/no") => handle_api_no(path), _ => ("404 Not Found", "text/plain", "Not Found".to_string()),