Reputation: 235
I have used pyramid to write a project. In a html page of the project, i want to use a button to call a python script, the python script is located in the path "myapp/Script".
I have this method tried but it dosn't work:
<script Language="javascript">
function call() {
http://localhost/Scripts/xxx.py
}
</script>
Thank you very much! :)
Upvotes: 2
Views: 343
Reputation: 83348
In most scenarios, the communicating from JavaScript to server-side is done using AJAX. Furthermore, most sites use jQuery JavaScript library to make AJAX programming easier.
AJAX requests are handled like any other HTTP requests in Pyramid.
Write a view in Pyramid (this is the "python script" part)
Then call it through AJAX
<script>
function call() {
$.ajax("/myurl/", function(result) {
console.log("I got this response from the server ", result)
});
}
</script>
Upvotes: 2