# HG changeset patch # User Jeff Hammel # Date 1557250767 25200 # Node ID 633487219ed67cbd9d8f5927047ec1fbd5826840 # Parent 1b6f0650dabb214d1658120b2387ad1204054c14 add web process waiter skeleton diff -r 1b6f0650dabb -r 633487219ed6 python/example/webwaiter.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/example/webwaiter.py Tue May 07 10:39:27 2019 -0700 @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +# https://stackoverflow.com/questions/473620/how-do-you-create-a-daemon-in-python + +""" +POST / +{ + "command": ["", ...] + "cwd": "" + "env: {"": ""} +} +-> +200 OK +{ + "pid": 123 +} + +GET /1 +{ + "returncode": null # or e.g. 2 + (stdout, stderr) +} +""" + +from webob import Request, Response + +class WebWaiter: + + def __call__(self, environ, start_response): + request = Request(environ) + res = Response(content_type='text/plain') + res.body = bytes("hello world", "utf-8") + return res(environ, start_response) + + +if __name__ == '__main__': + import argparse + import wgsiref + + parser = argparse.ArgumentParser(description=__doc__) + options = parser.parse_args()