Slide 22
Slide 22 text
Developing a Kitura web application
22
Kitura.addHTTPServer(onPort: 8090, with: router)
Kitura.run()
let router = Router()
router.get("/hello") { request, response, next in
response.status(.OK).send("
Hello, World!
").end()
}
6. Create and start an HTTPServer:
4. Add a router and a path:
router.get("/hello.json") { request, response, next in
response.status(.OK).send(json: JSON(["Hello": "World!"])).end()
}
5. Add a JSON data route