Skip to content

Instantly share code, notes, and snippets.

@burrussmp
Last active April 26, 2020 19:38
Show Gist options
  • Save burrussmp/82351c905cf022b129c909bb9c9837ac to your computer and use it in GitHub Desktop.
Save burrussmp/82351c905cf022b129c909bb9c9837ac to your computer and use it in GitHub Desktop.
A simply python server
import http.server
import socketserver
class Handler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/data': # handle any GET requests to /data
pass
elif self.path == '/annotation':# handle any GET requests to /annotation
pass
def do_POST(self): # handle general post event
pass
if __name__ == '__main__':
HOST_NAME = "YOURIPADDRESS"
PORT_NUMBER = 8080
httpd = socketserver.TCPServer((HOST_NAME, PORT_NUMBER), Handler)
print(time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER))
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
httpd.shutdown()
print(time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment