From 3587d0184ffb0ce59f8ef1bf0efc6869628951a1 Mon Sep 17 00:00:00 2001 From: binaryDiv Date: Sat, 27 Oct 2018 04:36:09 +0200 Subject: [PATCH] First code --- public_html/css/style.css | 0 public_html/index.html | 16 ++++++++++++++++ public_html/js/client.js | 0 server/chatserver.py | 22 ++++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 public_html/css/style.css create mode 100644 public_html/index.html create mode 100644 public_html/js/client.js create mode 100755 server/chatserver.py diff --git a/public_html/css/style.css b/public_html/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/public_html/index.html b/public_html/index.html new file mode 100644 index 0000000..7900342 --- /dev/null +++ b/public_html/index.html @@ -0,0 +1,16 @@ + + + + + + InstantChat + + + + +

InstantChat

+ + + + + diff --git a/public_html/js/client.js b/public_html/js/client.js new file mode 100644 index 0000000..e69de29 diff --git a/server/chatserver.py b/server/chatserver.py new file mode 100755 index 0000000..684604e --- /dev/null +++ b/server/chatserver.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +# Example code from: +# https://websockets.readthedocs.io/en/stable/intro.html + +import asyncio +import websockets + + +async def hello(websocket, path): + name = await websocket.recv() + print(f"< {name}") + + greeting = f"Hello {name}!" + + await websocket.send(greeting) + print(f"> {greeting}") + +start_server = websockets.serve(hello, 'localhost', 8765) + +asyncio.get_event_loop().run_until_complete(start_server) +asyncio.get_event_loop().run_forever()