Closed nishabe closed 9 years ago
If you use https://github.com/swisspol/GCDWebServer#serving-a-static-website then relative URLs like /myfile.css
will work. If using custom handlers, make sure you are installing handlers for the right paths.
Thanks, for the input.
The iOS code I am using is:
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
GCDWebServer* webServer = [[GCDWebServer alloc] init];
[webServer addGETHandlerForBasePath:@"/" directoryPath:path indexFilename:@"index" cacheAge:3600 allowRangeRequests:YES];
[webServer startWithPort:8080 bonjourName:nil];
The script file and the index.html are in the same directory. Still the issue persists.
Console logs below: [DEBUG] Connection received 294 bytes on socket 18 [DEBUG] Connection on socket 18 preflighting request "GET /d3.v3.min.js" with 294 bytes body [DEBUG] Connection on socket 18 processing request "GET /d3.v3.min.js" with 294 bytes body [DEBUG] Connection sent 104 bytes on socket 18 [DEBUG] Did close connection on socket 18 [VERBOSE] [127.0.0.1:8080] 127.0.0.1:54163 404 "GET /d3.v3.min.js" (294 | 104) [DEBUG] Did disconnect [DEBUG] Did end background task
Looks like your app is in background, see background mode info in README and #115.
When I do that my web view tries to download the index.html instead of rendering it. I tried in safari (macOS) and every time I point to index.html it gets downloaded
When I do that my web view tries to download the index.html instead of rendering it. I tried in safari (macOS) and every time I point to index.html it gets downloaded
+1
I am trying to run the GCDWebserver with a local HTML file. There is a script files that I am referring in this HTML file.
As of now I have given the remote URL path in the html file. eg:
How can give local path of this script file in the HTML string? I have tried 1) script src="/d3.v3.min.js"> and 2) script src="/Users/XXX/Library/Developer/CoreSimulator/Devices/40D2F2A5-342E-4468-A17B-415113BEBDF1/data/Containers/Bundle/Application/75F6C525-3063-41C2-B876-68CA4020BEC7/YYY.app/d3.v3.min.js">. Unfortunately both of them are not working. Do you have a suggestion?