AppDelegate.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // AppDelegate.swift
  3. // TestSwift
  4. //
  5. // Created by Damian Kolakowski on 05/06/14.
  6. // Copyright (c) 2014 Damian Kołakowski. All rights reserved.
  7. //
  8. import Foundation
  9. import UIKit
  10. @UIApplicationMain
  11. class AppDelegate: UIResponder, UIApplicationDelegate {
  12. var window: UIWindow?
  13. let server: HttpServer = HttpServer()
  14. func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
  15. server["/"] = { () -> (CInt, String) in
  16. return (200, "<html><body>Hello Swift</body></html>")
  17. }
  18. server["/hello"] = { () -> (CInt, String) in
  19. return (200, "<html><body>Hello !</body></html>")
  20. }
  21. server["/demo"] = { () -> (CInt, String) in
  22. return (200, "<html><body><center><h2>Hello Swift</h2>" +
  23. "<img src=\"https://devimages.apple.com.edgekey.net/swift/images/swift-hero_2x.png\"/><br>" +
  24. "<h4>\(UIDevice().name), \(UIDevice().systemVersion)</h4></center></body></html>")
  25. }
  26. let (result, error) = server.start(8080)
  27. return true
  28. }
  29. }