PP is a small Bash utility that makes it quick and convenient to start Python's built-in HTTP server from the terminal.
Instead of repeatedly typing:
python -m http.server
you can simply use:
pp
or specify the directory you want to serve:
pp ~/Desktop- π Start a Python HTTP server with one command
- π Serve a directory of your choice
- π Display your network interface information
- π Uses Python's built-in
http.server - π Works with Bash and Zsh
- β‘ Can be installed as a global terminal command
- π§ Designed for Linux
- Linux
- Bash
- Python 3
ipcommand (iproute2)
Check your Python installation:
python3 --version
Clone the repository:
git clone https://github.com/bear2305/pp-script.git
Enter the repository:
cd pp-scriptMake the script executable:
chmod +x pp
Run it:
./pp ~/DesktopYou should see something similar to:
Creating Server for: /home/user/Desktop
Serving HTTP on 0.0.0.0 port 8000
The server is available on port 8000.
On the same machine, you can open:
http://127.0.0.1:8000
A device on the same local network may be able to connect using your laptop's private IP:
http://YOUR-PRIVATE-IP:8000
./pp /path/to/directory
Example:
./pp ~/DesktopIf no argument is provided, pp uses the current directory:
./pp
For example, if you are currently inside:
~/Documents
then:
./pp
serves ~/Documents.
./pp -h
You can also use:
./pp --help
One of the ways to use pp is by placing the script in a directory that is included in your PATH. This allows you to run pp from any directory, without needing to type ./pp or specify the script's location.
A convenient standard location is:
mkdir -p ~/.local/binFrom the repository directory:
cp pp ~/.local/bin/ppMake it executable:
chmod +x ~/.local/bin/ppZsh
If you use Zsh, edit:
nano ~/.zshrcAdd:
export PATH="$HOME/.local/bin:$PATH"
Then reload your configuration:
source ~/.zshrc
Bash
If you use Bash, edit:
nano ~/.bashrcAdd:
export PATH="$HOME/.local/bin:$PATH"
Then reload:
source ~/.bashrc
.profile
You can also add the PATH entry to:
nano ~/.profileAdd:
export PATH="$HOME/.local/bin:$PATH"
You may need to log out and log back in for the change to take effect.
Run:
which pp
You should see something similar to:
/home/your-user/.local/bin/pp
Now pp can be used from anywhere:
pp ~/DesktopOr:
cd ~/Documents pp
pp is a Bash wrapper around Python's built-in HTTP server.
The main command used by the script is:
python -m http.server -d "$dirx"The script also checks the selected network interface and displays its IP information before starting the server.
By default, Python's HTTP server listens on:
0.0.0.0:8000
Be careful about what directory you serve.
When the server is running, files inside the served directory may be accessible to other devices that can reach your computer on the network.
For example:
pp ~/Desktopcould make files inside your Desktop directory available through the HTTP server.
Do not serve directories containing:
- Passwords
- SSH private keys
- API keys
.envfiles- Personal documents
- Credentials
- Other sensitive information
For temporary file sharing, it is safer to create a dedicated directory containing only the files you intend to share.
For example:
mkdir ~/shareCopy files into it:
cp file.txt ~/share/Then run:
pp ~/shareThe IP displayed by your network interface may be a private/local IP, such as:
10.x.x.x192.168.x.x172.16.x.xβ172.31.x.x
A private IP is normally used inside your local network and is not directly reachable from the public Internet.
Your public IP is different and is normally associated with your router/Internet connection.
Knowing your private IP does not expose your laptop directly to the Internet. However, you should still be careful when running network services, especially if your router has port forwarding configured or you are connected to an untrusted network.
$ pp ~/Desktop
Creating Server for: /home/user/Desktop
Serving HTTP on 0.0.0.0 port 8000
Then visit:
http://127.0.0.1:8000
from the same machine.
A device on the same local network may be able to use:
http://YOUR-PRIVATE-IP:8000
Press Ctrl+C to stop the server.
I wanted a simple way to start a Python HTTP server without repeatedly typing the full Python command.
After adding the script to my PATH, I can simply type:
pp
from anywhere and immediately start serving the current directory.
This project is intended for educational purposes, development, testing, and legitimate file sharing.
Only serve files and directories that you have permission to share. Use responsibly, especially when connected to public or untrusted networks.
Banahene Emmanuel Adamnor
If you find this project useful, feel free to β the repository.