Composing and sending HTTP requests
The HTTP server is running in Yocto Linux and waiting for our HTTP requests to control the LEDs on connected to the Intel Galileo Gen 2 board. Now, we will compose and send HTTP requests locally in Yocto Linux and then from other computer or devices connected to our LAN.
HTTPie supports curl-like shorthands for localhost. For example, :8888
is a shorthand that expands to http://localhost:8888
. We already have an SSH terminal running the HTTP server, and therefore, we can run the following command in another SSH terminal.
http GET :8888/version
The previous command will compose and send the following HTTP request: GET http://localhost:8888/version
. The request is the simplest case in our RESTful API because it will match and run the VersionHandler.get
method that just receives self
as a parameter because the URL pattern doesn't include any parameters. The method creates a response dictionary and then calls the self.write
method with response
as a parameter...