Created
February 15, 2022 18:32
-
-
Save C4PT41ND34DP00L/f644240a199fbf7c8e8b2af15f22fa11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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