This is a creation in Article, where the information may have evolved or changed.
Http://www.cnblogs.com/MikeZhang/archive/2012/02/11/httpFileSharePythonAndGo.html
In peacetime, there is no need for file sharing, so it is necessary to understand the method of file sharing.
There are many ways to file sharing, broadly divided into the following categories:
1. system Sharing (Windows sharing or samba , etc. ):
With Windows sharing, we can do simple file sharing under Windows , andLinux can be easily implemented with software like Samba .
2.FTP sharing:
It can be implemented with the help of common ftp software.
3.http sharing:
It can be implemented with common Web servers (such as IIS,Apache , and so on ) .
Today I'm going to introduce an http file share .
First, take IIS as an example to introduce the use of common Web server to implement file sharing method, as follows (in my machine example):
1. Open IIS, open "site -to-Default Web site", right click on "Properties", click " home Directory ", tick "directory browsing" option, as shown in :
2 , go to Folder C:\Inetpub\wwwroot , copy File " 1.7z " to this directory:
3 , open the browser, enter the native IP (for example, my: 192.168.1.123 ), you can see the shared files and download them:
Click "1.7z" to download.
I've implemented file sharing here, but how do I implement HTTP file sharing without Web server software such as IIS or Apache ?
Do not write a program to share files on their own Bai!
Oh, don't be frightened, this can be easily implemented with Python or the go language:
1.python implements http file sharing:
Python is known to have a very bull x command:
python-m Simplehttpserver
Run the command under C:\Python27 :
Open the browser to see the following effects:
The default port for this command is 8000, and if I add another port parameter, it can be accessed with a different port, with the following command:
Open your browser:
Know this principle, can write a bat file, when needed to copy to the corresponding directory double-click, such as my httpshare.bat file as follows:
Python-m Simplehttpserver 80
The default port, access time only need to enter my IP address.
2. TheGo language implements http file sharing:
The method above is very convenient, Windows and the Linux take all, but only if you want to install python
I have a use here . Go language implementation, but also Windows and the Linux All -In ( Windows below do not know how to configure the can refer to my previous article: http://www.cnblogs.com/MikeZhang/archive/2012/02/09/windowsGo.html ), similar C + + , is code portable, you only need to compile once before using.
Here is the sample code (httpshare.go):
Package mainImport ( "http" "fmt") func Main () { h: = http. Fileserver (http. Dir (". ")) var port string fmt. Printf ("") FMT. SCANF ("%s", &port) http. Listenandserve (":"+port, h) }
Operating effect:
Technology is for the service of life, think that simple to use that bar, anyway, the above several methods can achieve file sharing.
All right, that's it, I hope it helps you.