Interesting Tip Sourced from a Friend on HOW TO SERVE A Directory with python


2

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.

2replies
3voices
243views
tehron
5 years ago

0

For Python 2 (at least) there is also CGIHTTPServer., serving cgi-bin and htbin contents as CGI scripts.

Did you know Python is also shipped with an smtpd?

bl4ckh0l3
5 years ago

0

Yah…quick and dirty solution…it works like a charm!

You must be logged in to reply to this discussion. Login
1 of 3

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss