步骤:
1. install apache2
sudo apt-get install apache2
2. create symbolic link between local folder of data and web root path.
ln -s ~/test/data_folder /var/www/html/data
example:
ln -s /home/joanna/test/sql_savedata /var/www/html/data
3. test access to files via web url using brower:
http://localhost/data
http://localhost/data/S00/2020-10-14-15-22-32:450.png
4. modify and run download.py to download the image.png to local directory:
code:
import urllib.request
image_url = 'http://localhost/data/S00/2020-10-14-15-22-32:450.png' #local
#image_url = 'http://192.168.3.215/data/S00/2020-10-14-15-22-32:450.png' #other computers
save_name = 'my_image.png' #local name to be saved
urllib.request.urlretrieve(image_url, save_name)
说明:
出现报错:
Forbidden
You don't have permission to access this resource
解决办法:
修改本地文件夹权限,如
~/test/xxx$ chmod u=rw,g=rw,o=r *.png