-
Notifications
You must be signed in to change notification settings - Fork 554
Expand file tree
/
Copy pathmain.swift
More file actions
35 lines (27 loc) · 767 Bytes
/
main.swift
File metadata and controls
35 lines (27 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// main.swift
// SwifterOSX
// Copyright (c) 2015 Damian Kołakowski. All rights reserved.
//
import Foundation
import Swifter
do {
let server: HttpServer = demoServer(try File.currentWorkingDirectory())
server["/testAfterBaseRoute"] = { request in
return .ok(.html("ok !"))
}
server["/lightroom"] = { r in
print(String.fromUInt8(r.body))
// JSON().encode()
return .ok(.json(["result": "success"]))
}
if #available(OSX 10.10, *) {
try server.start(9080)
} else {
// Fallback on earlier versions
}
print("Server has started ( port = 9080 ). Try to connect now...")
RunLoop.main.run()
} catch {
print("Server start error: \(error)")
}