Working more on web server
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from Crypto.PublicKey.ECC import EccKey
|
||||
|
||||
from src.SantaExchange.Message import Message
|
||||
from src.SantaExchange.MessageHandler import MessageHandler
|
||||
from src.SantaExchange.SantasBrain import Brain
|
||||
from src.SantaExchange.UserInterface import UserInterface
|
||||
|
||||
|
||||
class ExchangeClient(MessageHandler, UserInterface):
|
||||
def __init__(self, send_message_function, receive_user_function, announce_recipient_function):
|
||||
MessageHandler.__init__(self)
|
||||
UserInterface.__init__(self)
|
||||
|
||||
self.send_message_function = send_message_function
|
||||
self.receive_user_function = receive_user_function
|
||||
self.announce_recipient_function = announce_recipient_function
|
||||
|
||||
self.brain = Brain(self, self)
|
||||
|
||||
def send_message(self, message: Message, signing_key: EccKey):
|
||||
message_string = message.generate_and_sign(signing_key)
|
||||
self.send_message_function(message_string)
|
||||
|
||||
def receive_user(self, name: str):
|
||||
self.receive_user_function(name)
|
||||
|
||||
def announce_recipient(self, name: str, other_info: str):
|
||||
self.announce_recipient_function(name, other_info)
|
||||
@@ -0,0 +1,23 @@
|
||||
import "./pyodide.js";
|
||||
|
||||
async function prepare() {
|
||||
let pyodide = await loadPyodide();
|
||||
await pyodide.loadPackage("pycryptodome");
|
||||
await pyodide.loadPackage("./santaexchange-0.1-py3-none-any.whl")
|
||||
pyodide.runPython(`
|
||||
class Test:
|
||||
def calculate(self):
|
||||
return 15
|
||||
|
||||
a = Test()
|
||||
`);
|
||||
|
||||
console.log('Running python function');
|
||||
console.log(pyodide.globals.get('a').calculate());
|
||||
}
|
||||
prepare();
|
||||
|
||||
addEventListener('message', e => {
|
||||
self.postMessage('Loading pyodide');
|
||||
self.postMessage('Loaded pyodide');
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
body {
|
||||
background-color: #fff7f7;
|
||||
color: #000000;
|
||||
text-align: center;
|
||||
font-family: 'Courier New';
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #d46a64;
|
||||
-webkit-text-stroke-width: 2px;
|
||||
-webkit-text-stroke-color: var(--header-stroke-color);
|
||||
font-size: 80px;
|
||||
font-family: 'Helvetica';
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.bodyDiv {
|
||||
width: 80vw;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
button {
|
||||
font-family: 'Courier New';
|
||||
font-size: 20px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
input {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 30vw;
|
||||
height: 20vh;
|
||||
}
|
||||
Reference in New Issue
Block a user