-
Notifications
You must be signed in to change notification settings - Fork 1
Connection between server hub and frontend
Give information about the decisions we made and how we are going to use them.
In How to connect to multiple robots we have learned that the amount of data that will need to be transferred is rather small. Because of this any regular modern laptop or computer will be sufficient.
Since we just want to receive requests and return some information an API is the best technology for our goal.
We don't need any complex data flow or functionalities so Flask (the go-to framework for easy-to-setup api's. With Flask you can easily wrap Python functions in API calls.) will be sufficient for our needs.
For example, normal code would look like this:
def hello_world():
return "Hello, World!"And when using Flask it would look like this:
app = Flask(__name__)
@app.route("/hello_world")
def hello_world():
return "Hello, World!"This function can now be called from anywhere in the local network with [server_ip]/hello_world and it will return the text "Hello, World!".
So let's say we have an app running on a mobile device that is connected to the local network. From the app we can send a request to the server and the server will make the RoboMaster move forward.
Ronacher, A. (2021). Welcome to Flask — Flask Documentation (2.0.x). Flask. Retrieved 17 November 2021, from https://flask.palletsprojects.com/en/2.0.x/

