diff --git a/main.py b/main.py index a903cb8..67e9ac8 100755 --- a/main.py +++ b/main.py @@ -22,6 +22,8 @@ class Meshenger: os.chdir(os.path.dirname(__file__)) # change present working directory to the one where this file is self.own_ip = self.get_ip_adress().strip() + # this hash is needed in clientserve, so client can generate color + self.own_hash = self.hasj(self.own_ip) if not os.path.exists(self.msg_dir): os.mkdir(self.msg_dir) diff --git a/meshenger_clientserve.py b/meshenger_clientserve.py index d5ae680..579bb46 100644 --- a/meshenger_clientserve.py +++ b/meshenger_clientserve.py @@ -24,6 +24,14 @@ Serve index and messages if self.path == '/index' or self.path.startswith( "/"+self.messageDir ): return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) + elif self.path == '/id': + if meshenger and meshenger.own_hash: + self.send_response(200) + self.send_header('Content-type', 'text-html') + self.end_headers() + self.wfile.write(meshenger.own_hash) + else: + self.send_error(404,'Id not yet available') elif self.path == '/log': self.send_response(200) self.send_header('Content-type', 'text-html') @@ -39,8 +47,7 @@ Serve index and messages self.path = '/'+f return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) - - else: + elif self.path == '/old': self.send_response(200) #serve the webapp on every url requested self.send_header('Content-type', 'text/html') self.end_headers() @@ -48,6 +55,10 @@ Serve index and messages with open( f, 'r') as the_file: self.wfile.write(the_file.read()) + else: + self.path = '/' + os.path.join('web', 'index.html') + return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) + def do_POST(self): """ diff --git a/web/.index.html.swo b/web/.index.html.swo index d158c50..aa83ec3 100644 Binary files a/web/.index.html.swo and b/web/.index.html.swo differ diff --git a/web/index.html b/web/index.html index f708dae..c0313c4 100644 --- a/web/index.html +++ b/web/index.html @@ -15,19 +15,35 @@