From 13058e09f5b420af863ed554c70ad046c1b04786 Mon Sep 17 00:00:00 2001 From: Christian van Dijk Date: Thu, 19 Feb 2026 17:18:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Update=20Readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d7b055..c1d9bfa 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,70 @@ -# GiteaTest +# 🚀 Tiny Lua HTTP Server -My First Gitea Repo \ No newline at end of file +A lightweight, zero-framework HTTP server built using **Lua** and **LuaSocket**. This project demonstrates how to handle basic routing, query parameter parsing, and manual HTTP response construction with a minimal footprint. + +![Lua Version](https://img.shields.io/badge/lua-5.1%2B-blue.svg) +![License](https://img.shields.io/badge/license-MIT-green.svg) + +## ✨ Features + +* **Zero Dependencies:** Only requires `luasocket`. +* **Minimal Footprint:** The entire server logic is under 50 lines of code. +* **Query Parsing:** Dynamically greets users via URL parameters. +* **Basic Routing:** Returns a `404 Not Found` for any path other than `/hello`. + +--- + +## 🛠️ Getting Started + +### 1. Prerequisites (macOS) + +Ensure you have **Homebrew** installed, then set up Lua and LuaRocks: + +```bash +# Install Lua and the Package Manager +brew install lua luarocks + +# Add LuaRocks to your shell path +eval $(luarocks path --bin) +``` +### 2. Install Dependencies +Install the networking library used by the server: +`luarocks install luasocket` +### 3. Run the Server +Clone this repository (or save the script as ⁠server.lua) and execute: +`lua server.lua` +The server will start at ⁠http://localhost:8080. + +--- + +## 📡 API Reference +The server currently supports a single endpoint: + +`/hello` +`HTTP GET` +`?name=YourName` (optional) +Returns a greeting. Defaults to "User". + +Examples +Greet a specific user: +`curl "http://localhost:8080/hello?name=Raycast"` +`Output: Hello Raycast!` + +Default greeting: +`curl "http://localhost:8080/hello"` +`Output: Hello User!` + +--- + +## 📂 Project Structure +- server.lua +Main server logic including socket handling and routing. +- README.md +Documentation and setup instructions. +--- + +## 🧠 How it Works + 1. Socket Binding: The server binds to ⁠localhost:8080 and waits for incoming TCP connections.
 2. Request Parsing: It reads the first line of the HTTP request and uses Lua's powerful Pattern Matching to extract the URI.
 3. Routing: It checks if the path matches ⁠/hello.
 4. Response: It manually constructs a valid HTTP/1.1 response string, including headers like ⁠Content-Type and ⁠Content-Length. + +## 📄 License +This project is open-source and available under the MIT License.