Skip to content

Commit f7689f5

Browse files
committed
Split CSS into separate file, vastly improve styling
1 parent b530a36 commit f7689f5

File tree

4 files changed

+132
-102
lines changed

4 files changed

+132
-102
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.idea/
33
.vscode/
44

5+
# Cached files
6+
__pycache__/

functions.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,43 +94,50 @@ def generate_checksum(body: str):
9494
logger.debug('CHECKOUT :' + chr(sum1) + ";")
9595
return chr(sum1)
9696

97+
9798
class listen_class:
9899
def __init__(self, listenList):
99100
self.messageList = listenList
100-
#self.messageList.append(messageList)
101+
# self.messageList.append(messageList)
102+
101103
def get_list(self):
102104
return self.messageList
105+
103106
def reset_list(self):
104107
self.messageList = []
108+
105109
def start_listen(self):
106-
t1 = Thread(target = self.listen, args = ())
110+
t1 = Thread(target=self.listen_test, args=())
107111
t1.daemon = True
108112
t1.start()
109-
def listen_test(self):#FOR TESTING
113+
114+
def listen_test(self): # FOR TESTING
110115
while True:
111116
message = input("What is your message?")
112117
self.messageList.append(message)
113118
print(self.messageList)
119+
114120
def listen(self):
115121
UDP_IP = "127.0.0.1"
116122
RX_PORT = 5557
117123
while True:
118-
msg_lstn = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
124+
msg_lstn = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
119125
msg_lstn.bind((UDP_IP, RX_PORT))
120126
ack, addr = msg_lstn.recvfrom(1024)
121127
#print (ack)
122128
time.sleep(1)
123-
#REDUDANCY CHECK
129+
# REDUDANCY CHECK
124130
if "to SATT4" in str(ack):
125-
#getTime()
126-
print ("RX: ", end="")
127-
print (ack)
131+
# getTime()
132+
print("RX: ", end="")
133+
print(ack)
128134
self.messageList.append(ack)
129-
#return(str(ack))
135+
# return(str(ack))
130136
#print ("RX: " + get_time(), end="")
131137
#print (ack)
132-
#print(ack)
133-
#self.messageList.append(ack)
138+
# print(ack)
139+
# self.messageList.append(ack)
140+
134141

135142
'''def listen_list():
136143
if(len(messageList) > 0):
@@ -221,6 +228,7 @@ def get_listen_message():
221228
#Thread(target=listen, daemon=True).start()
222229
'''
223230

231+
224232
def in_module(module):
225233
# get_time()
226234
# submod = input("UI: Which Module?\n")
@@ -326,13 +334,15 @@ def check_args(module, method, argList):
326334

327335

328336
def get_message(module, method, argList):
329-
checksum = generate_checksum('TJ' + module + ',' + method + ',' + print_arg(argList))
337+
checksum = generate_checksum(
338+
'TJ' + module + ',' + method + ',' + print_arg(argList))
330339
msg = "TJ" + module + "," + method + "," + print_arg(argList) + checksum
331340
return (msg)
332341

333342

334343
def send(module, method, argList): # ASSUMES EVERYTHING HAS BEEN CHECKED
335-
checksum = generate_checksum('TJ' + module + ',' + method + ',' + print_arg(argList))
344+
checksum = generate_checksum(
345+
'TJ' + module + ',' + method + ',' + print_arg(argList))
336346
msg = "TJ" + module + "," + method + "," + print_arg(argList) + checksum
337347
try: # Message successfully sent
338348
msg_snd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -341,4 +351,4 @@ def send(module, method, argList): # ASSUMES EVERYTHING HAS BEEN CHECKED
341351
return True
342352
except:
343353
return False
344-
#listen_list()
354+
# listen_list()

static/style.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@import url('https://fonts.googleapis.com/css?family=Work+Sans&display=swap');
2+
3+
body {
4+
margin: 0;
5+
padding: 20px;
6+
height: 100vh;
7+
overflow-x: hidden;
8+
}
9+
body,
10+
input {
11+
font-family: 'Work Sans';
12+
font-size: 16px;
13+
}
14+
input[type='text'] {
15+
margin-left: 15px;
16+
margin-bottom: 15px;
17+
transition: all 0.3s ease-in;
18+
padding: 10px;
19+
border: 1px solid slategray;
20+
}
21+
input:focus {
22+
border: 1px solid maroon;
23+
}
24+
25+
button {
26+
margin-top: 20px;
27+
font-family: 'Work Sans';
28+
font-size: 16px;
29+
border: 1px solid slategray;
30+
padding: 10px;
31+
background-color: white;
32+
transition: all 0.3s ease-in;
33+
cursor: pointer;
34+
}
35+
button:hover {
36+
border-color: maroon;
37+
background-color: snow;
38+
}
39+
40+
#app {
41+
display: grid;
42+
grid-template-columns: 50% 50%;
43+
}
44+
45+
#app h1 {
46+
margin-top: 0px;
47+
margin-bottom: 20px;
48+
}

templates/index.html

Lines changed: 58 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,65 @@
11
<!DOCTYPE html>
22
<html>
3+
<head>
4+
<title>Front-end</title>
5+
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}" />
6+
</head>
37

4-
<head>
5-
<title>Front-end</title>
6-
<style>
7-
body {
8-
margin: 0;
9-
padding: 10px;
10-
}
8+
<body>
9+
<div id="app">
10+
<div id="d-send">
11+
<h1>Send</h1>
12+
<form id="form">
13+
<label for="module">Module:</label><input type="text" name="module" /><br />
14+
<label for="method">Method:</label><input type="text" name="method" /><br />
15+
<label for="args">Arguments:</label><input type="text" name="args" /><br />
16+
</form>
17+
<button onclick="send()">Submit</button>
18+
</div>
19+
<div id="d-listen">
20+
<h1>Listen</h1>
21+
<p id="t-listen"></p>
22+
</div>
23+
</div>
24+
<script>
25+
function listen() {
26+
url = '/listen';
27+
fetch(url)
28+
.then(res => res.json())
29+
.then(jsonData => {
30+
if (JSON.stringify(jsonData) != '[]') {
31+
document.getElementById('t-listen').textContent = JSON.stringify(jsonData);
32+
}
33+
});
34+
}
35+
setInterval(listen, 7500);
1136

12-
body,
13-
input {
14-
font-family: 'Press Start 2P';
15-
font-size: 16px;
16-
}
37+
function send() {
38+
let form = new FormData(document.getElementById('form'));
39+
const url = '/send';
1740

18-
input[type='text'] {
19-
margin-left: 15px;
20-
margin-bottom: 15px;
21-
}
22-
23-
button {
24-
margin-top: 20px;
25-
font-family: 'Press Start 2P';
26-
font-size: 16px;
27-
}
28-
</style>
29-
<link href="https://fonts.googleapis.com/css?family=Press+Start+2P&display=swap" rel="stylesheet">
30-
</head>
31-
32-
<body>
33-
<form id="form">
34-
<label for="module">Module:</label><input type="text" name="module" /><br />
35-
<label for="method">Method:</label><input type="text" name="method" /><br />
36-
<label for="args">Arguments:</label><input type="text" name="args" /><br />
37-
</form>
38-
<button onclick="submit()">Submit</button>
39-
<script>
40-
function submit() {
41-
let form = new FormData(document.getElementById('form'));
42-
const url = '/send';
43-
44-
var request = new Request(url, {
45-
method: 'POST',
46-
body: JSON.stringify({
47-
module: form.get('module'),
48-
method: form.get('method'),
49-
args: form.get('args').split(',')
50-
}),
51-
headers: {
52-
Accept: 'application/json',
53-
'Content-Type': 'application/json'
54-
}
55-
});
56-
57-
fetch(request)
58-
.then(function (res) {
59-
// Handle response we get from the API
60-
console.log(res);
61-
})
62-
.catch(function (err) {
63-
console.log(err);
64-
});
65-
}
66-
</script>
67-
<p id="listen"> Listen messages</p>
68-
<script>
69-
function alertHi() {
70-
url = "/listen";
71-
fetch(url)
72-
//.then(res => res.json())
73-
//.then(jsonData => document.getElementById("listen").textContent = JSON.stringify(jsonData) + Math.random() * 10);
74-
.then(res=>res.json())
75-
.then((jsonData) => {
76-
if(JSON.stringify(jsonData) != "[]") {
77-
document.getElementById("listen").textContent = JSON.stringify(jsonData);
41+
var request = new Request(url, {
42+
method: 'POST',
43+
body: JSON.stringify({
44+
module: form.get('module'),
45+
method: form.get('method'),
46+
args: form.get('args').split(',')
47+
}),
48+
headers: {
49+
Accept: 'application/json',
50+
'Content-Type': 'application/json'
7851
}
79-
})
80-
/*fetch(url)
81-
.then((jsonData) => {
82-
// Handle response we get from the API
83-
//const thing = JSON.res;
84-
document.getElementById("listen").textContent = JSON.stringify(jsonData) + Math.random() * 10;
85-
console.log(jsonData);
86-
})
87-
.catch(function (err) {
88-
console.log(err);
89-
});*/
90-
}
91-
setInterval(alertHi, 7500);
92-
</script>
93-
</body>
52+
});
9453

95-
</html>
54+
fetch(request)
55+
.then(function(res) {
56+
// Handle response we get from the API
57+
console.log(res);
58+
})
59+
.catch(function(err) {
60+
console.log(err);
61+
});
62+
}
63+
</script>
64+
</body>
65+
</html>

0 commit comments

Comments
 (0)