Invoking a simple Web Server with Python on Parrot OS
within your command line terminal
type or copy and paste the following command
python -m SimpleHTTPServer {ENTER}
- Note: Please be security concious as you do this by not invoking this command
as the administrator{root}. This is merely for the safety of your own system’s
functionality.
Alternatively should your system have Python3 installed, within your command
line terminal, type or copy and paste the following command
python3 -m http.server {ENTER}
Additionally, should you desire to bind your required invocation to a specific
port, please refer to the example applied below:
[quote=author]python3 -m http.server 8800 {ENTER}[/quote]
to bind your desired web application/directory to a specific interface and port
please refer to the commandline parameters and syntax below:
[quote=author]python -m http.server 8100 –bind 127.0.0.1 {ENTER}[/quote]
- Critical Note: Initially it would be essential to first of all navigate to the
directory Folder you desire to share as a web service and then invoke the
commands based upon your preference in your commandline terminal.
After doing some research on stackoverflow.com {https://stackoverflow.com/%85/what-is-the-python-3-equivalent%85}, a nifty and time-saving method
can be applied by aliasing the command. One such interesting method which would
be extremely useful in whatever engagements that you may be performing is to
setup the alias with this interesting and useful commandline syntax Below:
[quote=author]alias serveThis=“python -m $(python -c ‘import sys; print("http.server” if sys.version_info[:2] > (2,7) else “SimpleHTTPServer”)’)“ {ENTER}[/quote]
Should the command be successful, all you then can do is simply navigate to the
webapp you want to share/test and or whatever, simply enter into your commandline
[quote=author][serveThis {ENTER}][/quote] and the command should be successfully applied.
Hope this information has and will be useful in your desired EDUCATIONAL pursuits.