Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c8b0492

Browse filesBrowse files
committed
can now handle POST operations
example web page templates/input.html
1 parent 8f89a5c commit c8b0492
Copy full SHA for c8b0492

File tree

5 files changed

+308
-102
lines changed
Filter options

5 files changed

+308
-102
lines changed

‎examples/webserver/myserver.m

Copy file name to clipboardExpand all lines: examples/webserver/myserver.m
+14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ function myserver() % called from C
77
case '/bob'
88
%webserver.template('templates/home.html', values);
99
stllog('in /bob');
10+
if webserver.isGET()
11+
stllog('GET request');
12+
end
1013
a = webserver.getarg('a');
1114
if ~isempty(a)
1215
stllog('a = %s', cstring(a));
@@ -19,4 +22,15 @@ function myserver() % called from C
1922
webserver.template('templates/alice.html', vals);
2023
case '/duck'
2124
webserver.file('duck.jpg', 'image/jpeg');
25+
case '/input'
26+
if webserver.isPOST()
27+
stllog('POST request');
28+
foo = webserver.postarg('Foo');
29+
stllog('foo = %s', cstring(foo));
30+
else
31+
stllog('GET request');
32+
end
33+
webserver.template('templates/input.html');
34+
end
35+
2236
end
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html>
2+
<body>
3+
<p>This is a page to test POST</p>
4+
<form action="" method="post">
5+
<p>Enter value of foo:
6+
<!-- POST key = Foo, POST value is entered tect -->
7+
<input type="text" value="0" name="Foo" />
8+
9+
<!-- button label is given by value, POST key = button, POST value = Button1/2 -->
10+
<p><input type="submit" value="Button1" name="button" /></p>
11+
<p><input type="submit" value="Button2" name="button" /></p>
12+
</form>
13+
</body>
14+
</html>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.