Merge branch 'main' of gitlab.fdmci.hva.nl:propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-3/qaajeeqiinii59

This commit is contained in:
Bram Barbieri
2024-03-14 14:30:44 +01:00
14 changed files with 343 additions and 123 deletions

View File

@@ -0,0 +1,16 @@
# Flask
## Introduction
Flask is a micro web framework written in Python. It is easy to use and has a lot of documentation. We are going to use Flask to serve our REST api.
## Cheatsheet
```python
print(f"Hello world have a nice {args}!")
```
This way you can put variables in a string. This is called f-strings.
## Rules for python
* You can only use one return statement in a function.

View File

@@ -16,7 +16,74 @@ We can only use certain ports like 113, 80, 443. These are common ports and are
A solution for this is to use a reverse proxy. (See [Reverse Proxy](./Reverse-Proxy.md))
## Classes
For the websockets we are going to use 2 classes. One for the nodes and one for the websites. The nodes are going to send data to the website and have multiple variables like temperature, humidity, eCO2, TVOC and sound. The website is going to send data to the nodes like names and settings. For this they have to use a userName and password.
``` mermaid
classDiagram
client --> User : website client
client --> Node : esp32 client
namespace raspberry pi clients {
class client {
+MacAdress
sendData()
}
class Node {
+eCO2
+Temperature
+Humidity
+TVOC
+Sound
+Settings
changeNodeName(name)
updateData(data)
}
class User {
+userName
+password
changeNodeName(data)
}
}
```
Code of the classes:
``` python
class client:
def __init__(self, macAdress):
self.macAdress = macAdress
class node(client):
def __init__(self, name, node, temperature, humidity, eCO2, TVOC, sound):
super().__init__(macAdress)
self.nodeNumber = node
self.temperature = temperature
self.humidity = humidity
self.eCO2 = eCO2
self.TVOC = TVOC
self.sound = sound
self.name = name
def updateData(self, temperature, humidity, eCO2, TVOC, sound):
self.temperature = temperature
self.humidity = humidity
self.eCO2 = eCO2
self.TVOC = TVOC
self.sound = sound
class Website(client):
def __init__(self, macAdress, user, password):
super().__init__(macAdress)
self.passWord = passWord
self.userName = userName
```
#### Sources:
* https://websockets.readthedocs.io/en/stable/index.html
**Written by Sam**
**Written by Sam & Sietse**