server python code example
Example 1: python3 webserver command line
python3 -m http.server
Example 2: python http server command line
python -m SimpleHTTPServer
Example 3: http.server python
python -m http.server 8000
Example 4: server on python
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()
Example 5: client server python socket
s = socket.socket (socket_family, socket_type, protocol=0)