What is it?So you have Raspberry Pi and you are creating lots of exciting new projects and code and you want to back them up or save them or even share them with others.
You can use USB pens but this can be a faff on, especially if you are away from the Pi and want to access it. What do you do? You will have heard of snake charming? Well Python can be charmed to serve you, well to serve your files.
Python has a really simple but powerful feature that can be used to share any file or folder from your Raspberry Pi. |
A Simple WebpageYou may be familiar with using HTML to code a webpage. The Python Server also doubles up as a simple method for hosting your webpage or website. Firstly,
|
Charming Example
How to Share
Load the LX Terminal and type:
python -m SimpleHTTPServer 8000
This sets up your Raspberry Pi as a simple web server that can now be accessed via any web browsers on another devices. You can view your files and open / download them by doing to another device and type in your IP Address, colon, 8000 into the address bar of your browser. For example, http://192.156.5.56:8000. If you do not know your IP Address,
Load the LX Terminal and type:
Hostname -I
This python command will probably share every single file / folder on your Raspberry Pi which is not really advisable or secure practice. It is therefore best to navigate to the folder that you want to share and then run the Python sever.
Load the LX Terminal and type:
cd nameofthefolderyouwanttoshare
python -m SimpleHTTPServer 8000
If you refresh your browser page F5 you should see that only the contents of this folder are now shared and accessible.
python -m SimpleHTTPServer 8000
This sets up your Raspberry Pi as a simple web server that can now be accessed via any web browsers on another devices. You can view your files and open / download them by doing to another device and type in your IP Address, colon, 8000 into the address bar of your browser. For example, http://192.156.5.56:8000. If you do not know your IP Address,
Load the LX Terminal and type:
Hostname -I
This python command will probably share every single file / folder on your Raspberry Pi which is not really advisable or secure practice. It is therefore best to navigate to the folder that you want to share and then run the Python sever.
Load the LX Terminal and type:
cd nameofthefolderyouwanttoshare
python -m SimpleHTTPServer 8000
If you refresh your browser page F5 you should see that only the contents of this folder are now shared and accessible.