Jam.py (web framework): Difference between revisions

Content deleted Content added
m adding no-code
m adding Hello World
Line 28:
 
== Example ==
The following code addsshows a formsimple button.web Whenapplication clicked,that thedisplays message"[[Hello willWorld]]!" showwhen andvisited:
asynchronous request sent to the server. After the server response, calculated_value field is updated and the message hidden.
 
Task/Client Module:
Server Module ([[Python (programming language)|Python]]):
<syntaxhighlight lang="python">
task.create_menu($("#menu"), $("#content"), {
import time
splash_screen: '<h1 class="text-center">Hello World!</h1>',
def calculate(item, params1, param2):
view_first: true
time.sleep(5)
return params1 + param2
</syntaxhighlight>
Client Module ([[JavaScript]]):
<syntaxhighlight lang="python">
function on_edit_form_created(item) {
let calc_btn = item.add_edit_button('Calculate');
calc_btn.click(function() {
let mess = item.message('Calculation in progress!', {close_on_escape: false, margin: 20, text_center: true});
item.server('calculate', [100, 200], function(result) {
item.calculated_value.value = result;
item.hide_message(mess);
});
});
}
</syntaxhighlight>