gcdwebserver

GCDWebServer static website on Swift

依然范特西╮ 提交于 2021-02-07 08:40:24
问题 I'm trying to make GCDWebServer show static content. I have code import UIKit import Foundation class ViewController: UIViewController { var webServer:GCDWebServer? let urlpath = NSBundle.mainBundle().pathForResource("index", ofType: "html", inDirectory: "www") override func viewDidLoad() { super.viewDidLoad() initWebServer() } func initWebServer() { webServer = GCDWebServer() webServer!.addGETHandlerForBasePath("/", directoryPath: urlpath, indexFilename: "index.html", cacheAge: 3600,

WKWebView not executing any js code

瘦欲@ 提交于 2020-01-25 07:48:13
问题 I am rendering a local index.html file inside my Xcode project, using WKWebView . The thing is, the html and css code inside the file are successfully displayed inside the webView, but the javaScript however, is not rendered at all. I have searched similar questions on this issue on stackoverflow and what I came up with is that Apple does not execute js in a local html file, and in order to execute js I am required to use a local webserver using GCDWebServer . To be honest I am new to the

How to implement Video Seek support with an embedded HTTP server on iOS?

不打扰是莪最后的温柔 提交于 2020-01-01 05:42:10
问题 I have a client iOS application that uses GCDWebServer to serve images and videos stored in the NSSearchPathDirectory.DocumentDirectory folder of the app on my device. Upon app startup, I start an instance of GCDWebServer and add a file response handler for my requests: self.addDefaultHandlerForMethod("GET", requestClass: GCDWebServerFileRequest.self) { request in return GCDWebServerFileResponse(file: self.filePathForResponse(request.URL)) } I can verify that while the app is running I can

iOS re-routing requests w/ GCDWebServer (not redirecting)

坚强是说给别人听的谎言 提交于 2019-12-24 18:51:14
问题 I want to create a server on iOS with GCDWebServer , which will accept request to localhost , and then, draw the data from another url (a video file) and stream the data to the response. I intend to use plain NSURLConnection , and in the didReceiveData of the NSURLConnection callback, I want to pass this data to the GCDWebServerResponse . I am having a hard time to figure out how can I keep the connection from a request open, so that I can initiate another request w/ NSURLConnection , and

Convert Ios Photo Album path url same like as Document directory File-path

不羁的心 提交于 2019-12-12 03:24:28
问题 As per my requirement, want to access iOS device photos app file url (not file as data) for my GCDWebUploader. I want assets library url for my web server. NSString* documentsPath =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; _webServer = [[GCDWebUploader alloc] initWithUploadDirectory: documentsPath]; // this is working and document directory files shown on browser. _webServer = [[GCDWebUploader alloc] initWithUploadDirectory:assetsUrl]; //

Invalid top-level type in JSON write

半城伤御伤魂 提交于 2019-12-11 00:04:59
问题 I'm trying to create a simple JSON object but I still get error and I know what's wrong in my code: NSString *vCard = [BRContacts getContacts]; // this is just a string, could be nil NSDictionary *JSONdic = nil; if (vCard) { JSONdic = [NSDictionary dictionaryWithObjectsAndKeys:@"1",@"status",vCard,@"data", nil]; } else { JSONdic = [NSDictionary dictionaryWithObjectsAndKeys:@"0",@"status",@"vCard is empty",@"error", nil]; } NSError *error = nil; NSData *JSONData = [NSJSONSerialization

How to set GCDWebServerOption_AutomaticallySuspendInBackground to NO

一笑奈何 提交于 2019-12-10 11:54:57
问题 I am new to iOS and swift with some experience in android. I am using the GCDWebUploader. Its working fine. The server suspends when the app is in background. I am aware of the constraints in iOS Background Execution. I dont want to change that behaviour. But I found in GCDWebServer documentation that we can disable this suspension. Check here https://github.com/swisspol/GCDWebServer#gcdwebserver--background-mode-for-ios-apps. Specifically this part If the app goes in the background while no

What is GCDWebServer for?

守給你的承諾、 提交于 2019-12-08 21:45:52
问题 I have a problem when loading the local web from WKWebView in iOS8. There are some suggestions that I should use GCDWebServer. I read through GCDWebServer, but not really understand what GCDWebServer is for on mobile application's side. Could you give me any practical case of using this library? Sorry for my ignorance. 回答1: It's a webserver that you can run on your iOS device. Just like you would run a webserver on VPS or dedicated server providers. This webserver that you would run and host