From 9aaa5f4b342a2aafae720d873724650d0e0646f4 Mon Sep 17 00:00:00 2001 From: Bofh Date: Wed, 10 Feb 2021 19:16:49 +0100 Subject: [PATCH] Now server accepts binding port or addr:port * Set it like this: python3 server.py 8081 or python3 server.py 127.0.0.1:8081 --- server.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index 093684a..58d5913 100644 --- a/server.py +++ b/server.py @@ -24,7 +24,20 @@ class MyServer(BaseHTTPRequestHandler): # lists accounts on a pretty HTML + CSS # making sure there is no XSS possible on account names elif parts[0] == 'mirrors': - self.wfile.write(bytes('HTML', "utf-8")) + html = """ + + + + Pixelfed IG Mirrors + + + +
{mirrors}
+ + +""" + self.wfile.write(bytes(html, "utf-8")) return @@ -74,10 +87,15 @@ class MyServer(BaseHTTPRequestHandler): if __name__ == "__main__": addr = '0.0.0.0' port = 8080 + if len(sys.argv) > 1: - addr = sys.argv[1] - if len(sys.argv) > 2: - port = sys.argv[2] + arg = sys.argv[1].strip() + if ':' in arg: + ps = arg.split(':') + addr = ps[0] + port = int(ps[1]) + else: + port = int(arg) webServer = HTTPServer((addr, port), MyServer) print("Server started http://%s:%s" % (addr, port))