Run a webserver on an iOS device

2019-02-04 22:02发布

问题:

I want to create an App that can share files between other iOS devices and potentially also Desktop computers.

So what I want to do is run a lightweight web server on my device that allows to download files from the device like so:

http://myphone.local:1234/folder/samplefile.txt

How can I provide such a server on a non-jailbroken device. I would prefer not to write a server like this from scratch :-).

Thanks a lot for your help

回答1:

Take a look at Cocoa HTTP Server



回答2:

According to the GitHub project:

CocoaHTTPServer is a small, lightweight, embeddable HTTP server for Mac OS X or iOS applications.

Sometimes developers need an embedded HTTP server in their app. Perhaps it's a server application with remote monitoring. Or perhaps it's a desktop application using HTTP for the communication backend. Or perhaps it's an iOS app providing over-the-air access to documents. Whatever your reason, CocoaHTTPServer can get the job done.