In my previous article I showed how you can transfer files from laptop to mobile with just a single command.
Inspired from the below comment. I decided to create a Python program which will generate a QR code and using that QR code you can access your laptop files in your mobile.
I saw an app that generates the QR code to access the file over LAN. I don't remember the name, but I think it's not that hard to write your own. That would be much simpler to get the file rather than typing 192.168.whatever in your browser and then finding the file.
#Import libraries
import socket
import http.server
import socketserver
import cv2
import pyqrcode
from pyqrcode import QRCode
from PIL import Image
Get IP address
hostname = socket.gethostname()
IP = socket.gethostbyname(hostname)
print("Your Computer IP Address is:" + IP)
url1
is a variable which will concatenate the IP ADDRESS and PORT number to form a string which will converted into a QR code and after that the http.server
will start running.
url1 = IP + ":" + "8000"
#Generate QR Code
url = pyqrcode.create(url1)
url.png("myqr.png",scale=8)
img = cv2.imread("myqr.png")
#print(type(img))
cv2.imwrite('myqr.png',img)
im = Image.open('myqr.png')
im.show()
#Start http server
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", 8000), Handler) as httpd:
print("Running your port")
httpd.serve_forever()
Now, save that file with name test.py
and run.
python test.py
After running,the QR code will pop up to your screen and the server starts running.
To access your files, scan the QR code and paste that link in your mobile browser.
NOTE: Your laptop and your mobile should be to same network
Code: GitHub
Top comments (1)
Nice article WhatsApp Status Video