Saturday 15 May 2010

python - Sending text from client-side to a server-side program for processing -



python - Sending text from client-side to a server-side program for processing -

my goal send line of text inputted user programme running server side processing. how can have html page upload text specific directory on server or straight python programme running on server?

when user submits form, or triggers other event, can run ajax request php script on server write text file. assuming jquery has been included simplicity's sake, can in html file:

$("#submitbutton").click(function() { $.ajax({ type: "post", url: "your/file/location/here/writetofile.php", data: {"text": $("#formfield").text()}, success: function() { alert("your info has been submitted"); } }); });

then php file on server this:

<?php $texttowrite = $_post['text']; fwrite("your/file/directory/here/data.txt", $texttowrite); ?>

this result in text file @ location your/file/directory/here named data.txt.

from there, should able have python script read file. can have php script execute python script if necessary.

python web

No comments:

Post a Comment