Python Web - Web Server

Card Puncher Data Processing


Web - Server in Python



  • Python 2: Linux Bash syntax
python -m SimpleHTTPServer 8888 &
  • for Python 3+
python3 -m http.server 8888 &


import socket


s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.setsockopt(socket.IPPROTO_IP, IP_TRANSPARENT, 1)

s.bind(('', 1234))
print("[+] Bound to tcp://")
while True:
    c, (r_ip, r_port) = s.accept()
    l_ip, l_port = c.getsockname()
    print("[ ] Connection from tcp://%s:%d to tcp://%s:%d" % (r_ip, r_port, l_ip, l_port))
    c.send(b"hello world\n")

After running the server you can connect to it from arbitrary IP addresses with netcat (nc)

nc -v 9999
Connection to 9999 port [tcp/*] succeeded!
hello world

The server will report the connection indeed was directed to port 9999, even though nobody actually listens on that IP address and port:

sudo python3
[+] Bound to tcp://
[ ] Connection from tcp:// to tcp://



Discover More
Admanager Homepage
Google Ad Manager - Getting started - How to show your first ad

A page on how to start with Google Ad Manager for a publisher. Got to Ad Manager Create an account if you don't have one (You need to have at minimal an adsense...
Card Puncher Data Processing
Python Web - Web Server Gateway Interface (WSGI)

The Web Server Gateway Interface (WSGI) is a interface that specify how web servers should forward requests to web applications or frameworks. It's written in the Python programming language. A...
Web - Server

A web server is a HTTP server that respond to HTTP request, generally returning a web page (HTML) (but it can serve any type of files). The request is handled: by native handlers (module) (if the server...

Share this page:
Follow us:
Task Runner