Skip to content

Bekacru/Sim-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sim Server

A toy web server written in swift.

Usage

import Sim

var app = Server()

app.get("/") {
  req in
  let html =
    "<!DOCTYPE html><html><body style='text-align:center;'><h1>Hello from Sim.</h1></body></html>"
  return Response(body: html, status: .ok)
}

app.get("/[id]") {
  req in
  let id = req.param["id"] ?? ""
  let html =
    "<!DOCTYPE html><html><body style='text-align:center;'><h1>id = \(id)</h1></body></html>"
  return Response(body: html, status: .ok)
}

do {
  try await app.serve()
} catch {
  print("Error serving: \(error)")
}

About

A toy web server written in swift.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages