diff options
author | matrix.org <matrix@matrix.org> | 2014-08-12 15:10:52 +0100 |
---|---|---|
committer | matrix.org <matrix@matrix.org> | 2014-08-12 15:10:52 +0100 |
commit | 4f475c7697722e946e39e42f38f3dd03a95d8765 (patch) | |
tree | 076d96d3809fb836c7245fd9f7960e7b75888a77 /demo/webserver.py | |
download | synapse-4f475c7697722e946e39e42f38f3dd03a95d8765.tar.xz |
Reference Matrix Home Server
Diffstat (limited to 'demo/webserver.py')
-rw-r--r-- | demo/webserver.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/demo/webserver.py b/demo/webserver.py new file mode 100644 index 0000000000..78f3213540 --- /dev/null +++ b/demo/webserver.py @@ -0,0 +1,39 @@ +import argparse +import BaseHTTPServer +import os +import SimpleHTTPServer + +from daemonize import Daemonize + + +def setup(): + parser = argparse.ArgumentParser() + parser.add_argument("directory") + parser.add_argument("-p", "--port", dest="port", type=int, default=8080) + parser.add_argument('-P', "--pid-file", dest="pid", default="web.pid") + args = parser.parse_args() + + # Get absolute path to directory to serve, as daemonize changes to '/' + os.chdir(args.directory) + dr = os.getcwd() + + httpd = BaseHTTPServer.HTTPServer( + ('', args.port), + SimpleHTTPServer.SimpleHTTPRequestHandler + ) + + def run(): + os.chdir(dr) + httpd.serve_forever() + + daemon = Daemonize( + app="synapse-webclient", + pid=args.pid, + action=run, + auto_close_fds=False, + ) + + daemon.start() + +if __name__ == '__main__': + setup() |