Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, make_server
from socketserver import ThreadingMixIn
import xbmc
from bottle import route, default_app
class SilentWSGIRequestHandler(WSGIRequestHandler):
"""Custom WSGI Request Handler with logging disabled"""
protocol_version = 'HTTP/1.1'
def log_message(self, *args, **kwargs):
"""Disable log messages"""
pass
class ThreadedWSGIServer(ThreadingMixIn, WSGIServer):
"""Multi-threaded WSGI server"""
allow_reuse_address = True
daemon_threads = True
timeout = 1
@route('/')
def index():
return 'Hello World!'
app = default_app
httpd = make_server('0.0.0.0', 8080, app,
server_class=ThreadedWSGIServer,
handler_class=SilentWSGIRequestHandler)
monitor = xbmc.Monitor()
while not monitor.abortRequested():
httpd.handle_request()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment