summaryrefslogtreecommitdiff
path: root/mwcfeedserver.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-19 08:38:15 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-19 08:38:15 +0200
commitb4d4867b851bb2f22bf18aa5f109bd2533d5736f (patch)
tree04b62d50d5e361902c945d29c95713f1a7655401 /mwcfeedserver.py
Initial import of mwc version 1.7.2-1
Diffstat (limited to 'mwcfeedserver.py')
-rwxr-xr-xmwcfeedserver.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/mwcfeedserver.py b/mwcfeedserver.py
new file mode 100755
index 0000000..98093b9
--- /dev/null
+++ b/mwcfeedserver.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python3
+
+# Copyright: (2013-2014) Michael Till Beck <Debianguru@gmx.de>
+# License: GPL-2.0+
+
+import http.server
+import socketserver
+import importlib
+import sys
+import getopt
+
+bind = 'localhost'
+port = 8000
+configMod = 'config'
+
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], 'hc:b:p:', ['help', 'config=', 'bind=', 'port='])
+except getopt.GetoptError:
+ print('Usage: FeedServer.py --config=config --port=8000')
+ sys.exit(1)
+
+for opt, arg in opts:
+ if opt == '-h':
+ print('Usage: FeedServer.py --config=config --bind=localhost --port=8000')
+ exit()
+ elif opt in ('-c', '--config'):
+ configMod = arg
+ elif opt in ('-b', '--bind'):
+ bind = arg
+ elif opt in ('-p', '--port'):
+ port = int(arg)
+
+config = importlib.import_module(configMod)
+
+
+handler = http.server.SimpleHTTPRequestHandler
+
+httpd = socketserver.TCPServer((bind, port), handler)
+
+print('Bond to ' + bind + ', listening on port ' + str(port))
+httpd.serve_forever()
+