Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a webserver on an iOS device

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

like image 478
Besi Avatar asked Dec 07 '11 14:12

Besi


People also ask

Can I run a Web server on iPhone?

Whether you're learning web development and want to host your own HTML files on your iPhone, or whether you just want to play around with a server without being restricted to using a laptop or a computer to install MAMP, your iPhone can do it for you.

Can an iPad be used as a server?

Want to run a simple web server off of an iPad or iPhone? If you have iSH linux shell running in iOS then you can easily start and run a simple web server directly from an iPhone or iPad.

Can I run localhost on iPhone?

Accessing localhost from the iPhone will simply do a loopback / try to connect to itself (If it supports that?). What you need to do is find the IP of your desktop machine (e.g. If Windows, go to the Command Prompt and type ipconfig or go to Network and Sharing Centre and look up connection status .


2 Answers

Take a look at Cocoa HTTP Server

like image 103
tilo Avatar answered Oct 21 '22 13:10

tilo


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.

like image 23
Foo Avatar answered Oct 21 '22 12:10

Foo