using System; using HttpServer; class Program { static void Main() { HttpServer server = new HttpServer(); server.UrlHandler.Register("Hello World", (req, res) => { res.Write("Hello World"); res.Send(); }); server.Start(8080); } }
using System; using HttpServer; class Program { static void Main() { HttpServer server = new HttpServer(); server.UrlHandler.RegisterFile("*", (req, res) => { res.ContentType = FileUtil.GetMimeType(req.Path); res.WriteFile("public" + req.Path); res.Send(); }); server.Start(8080); } }This creates an HttpServer that serves static files located in the "public" directory. It detects the proper MIME type based on the file's extension. HttpServer is an open-source package that can be found on NuGet.