Google Plus

Start Simple HTTP Server with Python

Written by Mel Kham on . Posted in Linux tutorials

This methode wil install the webserver in The same directory where you apply the python command.

The command will read automaticly the index.html page . if there is no index.html will list the contents of the directory .

 

 

So lets start

cd /var/www/html
[root@test11 html]# ls

info.php

[root@test11 html]# touch index.html
[root@test11 html]# view index.html

(make your Welcome text message)

[root@test11 html]# python -m SimpleHTTPServer

Serving HTTP on 0.0.0.0 port 8000 …

Test11.unixmen.com – - [23/Sep/2009 07:00:29] “GET / HTTP/1.1″ 200 –

Now open your browser with

http://localhost:8000 or http://127.0.0.1 or http://IP:8000

 

Other way you can change the web port with :

python -m SimpleHTTPServer 8081 or other  port

If you want to make your server local in your intern LAN of Only on this server edit this Pyhton script :

 

import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('127.0.0.1', port)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)

sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()

 

Enjoy

 

 

For questions please refer to our Q/A forum at : http://ask.unixmen.com

Mel Kham

Founder of Unixmen, Living in Amsterdam. Am working in my free time to help people to understand the Opensource and to explain them in easy way how to make the fist steps to the the light. Working day and night with my Co-founder Zinovsky to keep this website live even with less resources.

Like us on Facebook

This week Top Posts

Write for us

Recent Comments

jacky can

|

You can actually unzip your secret archive by leaving out the -t option, instead using:

unzip newPhoto.jpg

DragonFartOutLoud

|

it went to china.

DragonFartOutLoud

|

great review! i’ve been using it as my main OS since Beta 1 release. its been a awesome ride so far :)

jet li

|

i try the method, and i unzip the image contain zip secret, i dont find the file that i was hide, where it go? and how to open it? :s

zinovsky

|

Yes, it is possible using Steganography, we will post another quick howto do that in the next few days

 
IDG Tech Network
Copyright © 2008-2013 Unixmen.com .
Maintained by Anblik .