You are not logged in.

#1 2019-10-29 00:15

JimW
Member
Registered: 2015-12-08
Posts: 359

Very Simple HTTP server

many, like myself, may not know that they have a very simple HTTP server. If they want to serve up a webpage on their computer or local network they don't need to install Apache or similar.
First - you do need python
You can check if you have it and which version by typing "python" (exit with ctl D)
Should give you something like this:

$ python
Python 2.7.16 (default, Apr  6 2019, 01:42:57)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>ctl D

as you can see I have version 2.7.16
to start the server simply type:

$ python -m SimpleHTTPServer 8080

the 8080 is the port you will run on. If you do not enter a port it will run on 8000! It will generate an html listing of the folder you are running from.  But if you want to use an index.htm the server will recognize that and use it instead.
Start your web browser and enter localhost:8080 and you should see the listing of whatever is in your folder. This works the same from any local computer, just enter the ip address instead of localhost. For me, I would enter 192.168.1.8:8080
You can now transfer files from your 'server' to other computers on your lan! If you have movies or audio you can watch them on the other computers without having to download them.
The terminal you started the program from is your log, it will show connections and errors. I guess you could re-direct it to a file if you wanted a more permanent record.
When finished just go back to the terminal you started it from and press ctl C to break the program. If you have put it in the background then you would have to find the pid and kill it with the kill command.

WARNING!!
There is no configuration with this program and no security. I would suggest you only use it for short periods and not leave it running!

Note:
if you have python 3.x or above you might try

python -m http.server

Offline

Board footer

Powered by FluxBB