You can set the server action in the App Properties on the page

Output of the server connect should be directly accessible like <%= $_POST.input1 %>, you can also use expressions with <%= _('$_POST.input1.lowercase()') %>.
EJS templates are just javascript, so looping over data could be done like:
<ul>
<% for (const item of query1.data) { %>
<li><%= item.label %></li>
<% } %>
</ul>