pyserv package¶
Submodules¶
Module contents¶
Simple HTTP server classes with GET path rewriting and request/header logging. Now includes a reference WSGI server and tftpdaemon script.
- class pyserv.GetHandler(*args, directory=None, **kwargs)[source]¶
Bases:
SimpleHTTPRequestHandler
Munge the incoming request path from Dialog OTA. Runs urlparse on the url and updates the GET handler path. We also log the result.
- class pyserv.GetServer(iface, port, directory='.')[source]¶
Bases:
Thread
Threaded wrapper class for custom ThreadingHTTPServer instance.
Usage:
s = GetServer('', 8080) s.start() s.stop()
- class pyserv.GetServerWSGI(flask_app, port, is_flask=False, validate=False)[source]¶
Bases:
Thread
Threaded wrapper class for custom flask WSGIServer instance.
Usage:
s = GetServerWSGI(my_app, 8080, is_flask=True, validate=False) s.start() s.stop()
- class pyserv.RepeatTimer(interval, function, *args, **kwargs)[source]¶
Bases:
object
A non-blocking timer thread to execute a user func repeatedly. Usage:
def hello(name): print(f"Hello {name}") rt = RepeatTimer(1, hello, "World") # it auto-starts try: sleep(5) # run other stuff finally: rt.stop() # best in a try/finally block
Author: https://stackoverflow.com/a/38317060/14874218
- Parameters:
interval (int | float)
function (Callable)