File: simple_http_server.py

package info (click to toggle)
aseba-plugin-blockly 20180211%2Bgit-3
  • links: PTS
  • area: non-free
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 64,568 kB
  • sloc: javascript: 504,479; xml: 7,976; python: 2,314; sh: 261; lisp: 24; makefile: 10
file content (27 lines) | stat: -rwxr-xr-x 729 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
import cgi
import sys

PORT = 8080

# Simple server to respond to both POST and GET requests. POST requests will
# just respond as normal GETs.
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):

    def do_GET(self):
        SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)

    def do_POST(self):
        SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)

Handler = ServerHandler

# Allows use to restart server immediately after restarting it.
SocketServer.ThreadingTCPServer.allow_reuse_address = True

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

print ("Serving at: http://%s:%s" % ("localhost", PORT))
httpd.serve_forever()