First we need to install Python 3.x, if using Linux please refer to [Build Python Environment in Linux][2]. If using Windows, you can download from official straightly: https://www.python.org/downloads/windows/, The .zip file is portable version, other versions need installation.
(Windows Users)Go to the folder to share, right click with SHIFT
, choose Open Powershell in this folder
or Open command line in this folder
.
Type command python3 -m http.server
(python3
might be replaced by python
or py
), it uses port 8000 for default.
In order to use a specific port, type python3 -m http.server <PORT>
. To designate the folder, type python3 -m http.server -d <FOLDER NAME>
.
There is some more things to do with Portable version, you have to type the full path of Python executable program instead of the abbreviations like python
.
To make a .py script, create a new file and type content below,
|
|
References: