Expose a web server on local network

  1. Connect your laptop and phone to the same network (Wi-Fi is a network too).

  2. Create a index.html file to share:

<div>Hello!</div>
  1. Start a web server in the same directory as the file:
ruby -run -e httpd -- --bind-address=0.0.0.0 --port=9090
  1. Find your hostname, or ip address:
hostname
# my-pc

ip addr
# ... some wall of text, one line containing something like:
# inet 192.168.0.38/24 ...
  1. Now you can use either your hostname or ip address to access your web page from your phone:
http://my-pc:9090/index.html

http://192.168.0.38:9090/index.html
  1. Install Termux on your phone and do the exact same to access web pages from your laptop.