Skip to content

Commit 68d09fb

Browse files
committed
update webserver example
1 parent b97386b commit 68d09fb

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

examples/webserver/myserver.m

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
function myserver() % called from C
1+
function myserver() % called on every page request
22

33
switch (webserver.url())
44
case '/'
5-
stllog('in /')
5+
stl.log('in /')
66
webserver.html('home here');
7-
case '/bob'
8-
%webserver.template('templates/home.html', values);
9-
stllog('in /bob');
7+
case '/page1'
8+
stl.log('in /page1');
109
if webserver.isGET()
11-
stllog('GET request');
10+
stl.log('GET request');
1211
end
1312
a = webserver.getarg('a');
1413
if ~isempty(a)
15-
stllog('a = %s', cstring(a));
14+
stl.log('a = %s', cstring(a));
1615
end
17-
webserver.html('<html><body>hello <b>from</b> /bob</body></html>');
18-
case '/alice'
19-
stllog('in /alice')
16+
webserver.html('<html><body>hello <b>from</b> /page1</body></html>');
17+
case '/page2'
18+
stl.log('in /page2')
2019
vals.a = 1;
2120
vals.b = 2;
22-
webserver.template('templates/alice.html', vals);
21+
webserver.template('templates/page2.html', vals);
2322
case '/duck'
2423
webserver.file('duck.jpg', 'image/jpeg');
2524
case '/input'
2625
if webserver.isPOST()
27-
stllog('POST request');
26+
stl.log('POST request');
2827
foo = webserver.postarg('Foo');
29-
stllog('foo = %s', cstring(foo));
28+
stl.log('foo = %s', cstring(foo));
3029
else
31-
stllog('GET request');
30+
stl.log('GET request');
3231
end
3332
webserver.template('templates/input.html');
34-
end
35-
33+
end
3634
end

examples/webserver/user.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function user() %#codegen
22

3-
stllog('user program starts');
3+
stl.log('user program starts');
44

55
webserver(8080, 'myserver');
66

7-
sleep(60);
7+
stl.sleep(60);
88
end

0 commit comments

Comments
 (0)