A lightweight, zero-configuration HTTP server written in Ruby to share files from your computer to any device on your local network. It provides a clean, mobile-friendly web interface and a QR code for instant access.
- Cross-Platform: Works on any system with Ruby installed (macOS, Linux, Windows).
- QR Code Support: Generate a QR code for easy access to the server URL on mobile devices.
- Configurable: Use command-line flags to change the port, show the QR code, or get help.
- Flexible: Serve files from any directory on your computer.
- Ruby (tested with Ruby 2.x and 3.x)
webrick(usually included with Ruby)rqrcode-coregem: This gem is required for the QR code functionality. If you use the-qroption and encounter an error, you may need to install it:gem install rqrcode
Since local_server is a Ruby script, you'll need a Ruby environment set up. Most macOS and Linux distributions come with Ruby pre-installed.
-
Save the script: Save the provided Ruby code into a file named
local_server.rb(or any other name you prefer). -
Make it executable:
chmod +x local_server.rb
-
Move to your PATH: For easy execution from any directory, move the script to a directory included in your system's
PATH(e.g.,/usr/local/binor~/bin).mv local_server.rb /usr/local/bin/
If
/usr/local/binrequires superuser permissions, you might need to usesudo:sudo mv local_server.rb /usr/local/bin/
Once installed, you can run local_server.rb directly from your terminal.
To serve files from your current directory:
local_server.rbThis will start the server on port 8000 (by default) and display the local URL.
To serve files from a different directory (e.g., your Downloads folder):
local_server.rb ~/DownloadsTo run the server on a different port (e.g., 3000):
local_server.rb -p 3000To get a QR code for the server URL, which is handy for quickly accessing it on your phone:
local_server.rb -qrYou can combine options:
local_server.rb ~/Pictures -p 8080 -qrTo stop the server, press Ctrl+C in your terminal.
-
Sharing a photo album with your phone:
local_server ~/Photos/Vacation2024 -qrScan the QR code with your phone's camera, and you'll be able to browse and download your photos.
-
Quickly transfer a document to another computer on your network:
local_server ~/DocumentsThen, on the other computer, open a web browser and navigate to the IP address and port displayed in your terminal (e.g.,
http://192.168.1.100:8000).
Feel free to open issues here or submit pull requests on this repository.
This project is licensed under the MIT License.