Download Files From Your Computer By Your Phone - zamaniamin/python GitHub Wiki
The command python -m http.server 8000
is used to start a simple HTTP server on your computer, and it allows you to serve files from your computer to other devices on your local network. If you want to access this server from your phone, both your phone and your laptop need to be on the same local network (e.g., connected to the same Wi-Fi network).
Here's how you can connect your phone to the laptop's HTTP server using this command:
-
Start the HTTP Server: Open your terminal or command prompt on your laptop, navigate to the directory where your files are located (or where you want to serve files from), and run the following command:
python -m http.server 8000
This will start the HTTP server on port 8000 by default. You can specify a different port number if you prefer.
-
Find Your Laptop's IP Address: To connect your phone to your laptop, you need to know your laptop's local IP address. You can find this by running the following command on your laptop:
- On Windows, use
ipconfig
in the command prompt and look for the "IPv4 Address" under your active network adapter. - On macOS or Linux, use
ifconfig
orip addr
in the terminal and look for the "inet" address associated with your network adapter (usually something like 192.168.x.x).
- On Windows, use
-
Access the Server from Your Phone: On your phone, open a web browser and enter the following address:
http://<your_laptop_ip>:8000
Replace
<your_laptop_ip>
with the IP address you found in step 2. -
Access Files: You should now be able to access and browse the files in the directory where you started the HTTP server on your laptop. You can click on files to view or download them directly to your phone.
Remember that this connection is only accessible within your local network. If you want to access your laptop's server from outside your local network (e.g., over the internet), you would need to configure port forwarding on your router and possibly use dynamic DNS (DDNS) if you have a dynamic IP address.