Skip to content

Instantly share code, notes, and snippets.

@KonstantinBerkow
Last active February 23, 2018 18:33
Show Gist options
  • Save KonstantinBerkow/39b7cfc8178f6be42600410b144c4b9e to your computer and use it in GitHub Desktop.
Save KonstantinBerkow/39b7cfc8178f6be42600410b144c4b9e to your computer and use it in GitHub Desktop.
let queueu = DispatchQueue.global(qos: DispatchQoS.background.qosClass)
Alamofire.request("\(apiURL)/params/pages").responseJSON(queue: queueu) {
response in
guard response.result.isSuccess,
let jsonArr = response.result.value as? [JSON] else {
return
}
var newPages: [String: String] = [:]
for obj in jsonArr {
if let key = obj["key"] as? String,
let value = obj["value"] as? String {
newPages[key] = """
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/css/bundle.css">
<link rel="stylesheet" type="text/css" href="/build/application.css">
</head>
<body>\(value)</body>
</html>
"""
}
}
DispatchQueue.main.async {
HtmlController.pages = newPages
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment