Reputation: 25
I need to make an HTTP web service or an HTTP action page, hosted on the iPad or any iOS device.
This service should be accessible from other devices connected on the same network using HTTPRequest
, or using NSURLConnection
.
Any suggestion will be useful.
Upvotes: 2
Views: 124
Reputation: 50089
You would need a web server written in cocoa that runs inside your app and provides access to files via HTTP
shameless plug: see my DDSimpleHTTPd -- it is a basic webserver that runs on iOS devices
https://github.com/Daij-Djan/DDSimpleHTTPd
in your viewController / appDelegate you start it like this to server any files in the specified dir:
NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSString *path = url.path;
SimpleHTTPResponder *simpleServer = [[SimpleHTTPResponder alloc] init];
simpleServer.port = 8000;
simpleServer.webRoot = path;
simpleServer.bonjourName = @"test"; //optional: allow it to be found via bonjour
simpleServer.loggingEnabled = YES; //optional: do NSLogs of the requests that come in
simpleServer.autogenerateIndex = YES; //optional: generate a directory overview
[simpleServer startListening];
Upvotes: 2