import clacks # -- create a simple server instance. # -- All keyword arguments can be left to their default in most cases. server = clacks.ServerBase(identifier='My First Clacks Server') # -- create a handler. Handlers are how the Server receives input requests. handler = clacks.JSONHandler(clacks.JSONMarshaller(), server=server) # -- once a handler has been created, it needs to be registered on a host/port combo. server.register_handler_by_key(host='localhost', port=9998, handler_key='simple', marshaller_key='simple') # -- give the server something to do - the "standard" interface contains some basic methods. server.register_interface_by_key('standard') # -- start the server. By setting "blocking" to True, we block this interpreter instance from progressing. # -- Setting "blocking" to False instead would not stop this interpreter instance from continuing, so the server # -- would die if the interpreter instance reaches its exit point. server.start(blocking=True)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter