web servers for the internet of things
TRANSCRIPT
Web servers for the Internet of ThingsSUMMER SCHOOL
2
Outline
Web server
HTTP
Gadgets
IoT Webserver
Web templates
Web services
Web socket
Questions
3
Web server
4
What is a web server Software that implements HTTP/HTTPS
Mainframes
Computers
Gadgets
5
Gadgets?!
6
What HTTP? Widely used
Easy to implement
Text based
HTML◦ Simple and flexible UI◦ JavaScript runs in almost any browser◦ Replace displays
7
UI Gadgets prefer HTML UI
Accessible from the tablet
Wireless “display”
Web language
Gadgets are using less displays
Expensive
Fixed
Special software
8
HTTP
9
HTTP
Image from https://www3.ntu.edu.sg/home/ehchua/programming/webprogramming/HTTP_Basics.html
10
HTTP Request
◦ Headers◦ Method◦ URL◦ Query String◦ Upload body
Response◦ Status◦ Headers◦ Data
11
Query http://address[:port]URL?querystring
http://wyliodrin.cs.pub.ro/projects?show=true
Address?
Port?
URL?
querystring?
12
Query http://address[:port]URL?querystring
http://wyliodrin.cs.pub.ro/projects?show=true
Address? wyliodrin.cs.pub.ro
Port? 80
URL? /projects
querystring? show=true
13
Methods GET
◦ Request objects without sending data
POST◦ Modify objects with data that you are sending
PUT◦ Create new objects with data that your are sending
DELETE◦ Delete objects without sending data
14
HTTP
Image from https://www3.ntu.edu.sg/home/ehchua/programming/webprogramming/HTTP_Basics.html
15
Gadgets
16
Webserver for the gadgets
17
Web Web request
◦ Starts a webserver◦ Sets up static folder◦ Stores
◦ Html◦ Javascript◦ Css
http://address:port/static/index.html
18
Web Web request
◦ Route◦ Method◦ Port
Message
{
payload: query string / upload data
req: request
res: response
next:
}
19
Web response Web response
◦ Input from a web request◦ Sends the payload◦ Redirect
http://address:port/ redirects to http://address:port/static/index.html
20
Run the server Get the IP of the board
◦ Shell ◦ ifconfig
In the same network
http://172.17.0.82:5000/
21
IoT Server
22
IoT Server Server with public IP address
A gadget without pin access
Good for web server◦ Web pages◦ API
23
IoT Server
24
Web templates
25
Web template Web template
◦ Loads a templates◦ Fills it with variables
◦ From value◦ From payload
◦ Sends it
26
Web template• Values are available• Payload variables are available
27
Web template
Value is refreshed only on a page reload
28
Web service
29
Web service is API Expose functions for apps
◦ Mobile Applications◦ Refresh the value without reloading the page◦ Use multiple UI
Image from http://blogs.msdn.com/b/martinkearn/archive/2015/01/05/introduction-to-rest-and-net-web-api.aspx
30
Web response Web response
◦ Input from a web request◦ Sends the payload◦ Redirect
31
Web response /sensor returns
{
“sensor”: “0”
}
32
JQuery API
33
Web socket
34
Websocket Allows asynchronous communication with the server
◦ Like a socket◦ Uses HTTP or HTTPS◦ Problems with proxies
Socket.IO◦ Has a solution with HTTP or HTTPS if the websocket is unavailable
35
Websocket
Image from https://warmcat.com/libwebsockets/2010/11/01/libwebsockets-html5-websocket-server-library-in-c.html
36
Web starter app Streams
Web starter app
Angular JS
37
Angular JS static/web.html
38
Javascript
39
Questions?