Wednesday, June 8, 2016

Simple Webserver to host/share files in Python

server.py

import SimpleHTTPServer
import SocketServer

PORT = 80

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

httpd = SocketServer.TCPServer(("", PORT), Handler)

print "serving at port", PORT
httpd.serve_forever()


Use sudo to use port 80
$ sudo python server.py


or
$ sudo yum install python-pip
#pip install SimpleHTTPServer
$ sudo python -m SimpleHTTPServer 80


#firefox http://localhost/

No comments:

Blog Archive