Skip to content

Instantly share code, notes, and snippets.

@C4PT41ND34DP00L
Created February 15, 2022 18:32
Show Gist options
  • Save C4PT41ND34DP00L/f644240a199fbf7c8e8b2af15f22fa11 to your computer and use it in GitHub Desktop.
Save C4PT41ND34DP00L/f644240a199fbf7c8e8b2af15f22fa11 to your computer and use it in GitHub Desktop.
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