How to Run a Simple Web Server on iPad or iPhone

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. By running iSH and starting a web server with python 3 you can then serve either HTML files or a directory listing to the same device via localhost, or to anyone on the same network with the iOS devices IP address. This is obviously not going to be as fully functional or featured as running apache or nginx, but if you want to geek around with a simple local html development environment or serve something via http from an iPhone or iPad, it’ll do the trick. Plus, it’s just plain cool.

How to Run a Web Server on iOS with iSH and python

  1. Install iSH on the iPhone or iPad as directed here if you haven’t done so already, otherwise launch iSH
  2. At the iSH command line in iOS, enter the following syntax and hit return:
  3. python3 -m http.server

  4. When you see the ‘Serving HTTP on 0.0.0.0 port 8000’ message, now you’re ready to connect the web server from either the same device or another:
  5. Python simple web server running on iOS

  • To connect to the iOS web server from the same device (localhost), point any web browser to:
  • http://127.0.0.1:8000
    Loading web server from localhost on iPad

  • To connect to the iOS web server from another device on the same network, point any web browser to:
  • http://DEVICE-IP-ADDRESS:8000
    Replacing ‘DEVICE-IP-ADDRESS’ with the IP address of the device running iSH and the python web server, you can find the iOS devices IP address in Network Settings if needed. (Example screenshot shows the iOS device IP of 192.168.1.10)
    Loading the iOS web server from another iOS device on the same network

Pretty cool, right?

You’ll probably want to put some basic index.html file at the present working directory where you’re running the python server from. If you don’t have a simple index.html file in the current working directory on the iOS device where the python command is being run, then a simple directory listing is shown instead.

While the simple web server is running, you’ll see standard logging information appear in the iSH terminal window, showing access times, dates, IP addresses, GET and PUSH requests, 404 errors, and other typical access log information.

Simple web server on iOS showing access logs

We’re obviously going with the python3 web server command here, but you can also use the Python 2 instant web server if you’d prefer, since both python2 and python3 are available on iSH.

Anyway, while the isn’t a particularly practical solution to web hosting or web development and you likely won’t be using this for anything too serious, it’s still fun and interesting as a proof of concept for us geekier folks. Perhaps one day we’ll get some easy web server setup in the iOS world like MAMP for Mac, but until then the solutions are fairly limited and most web workers and developers will continue to be using ssh to connect to a web server for the time being.

If you know of any other interesting or geeky solutions for setting up a web server or web sharing natively with an iOS device, share with us in the comments!

Source: OSX Daily