Reputation: 397
i have an html file,
<html>
<body>
<form action="http://localhost/mypgm.py">
<input type="textbox" name="id" />
<input type="submit" />
</form>
</body>
</html>
In mypgm.py i have to process the value entered in the text-box and respond with an appropriate html.. how do i do that?
i mean how do i read the HTML parameter value inside python??
i have Python 2.3.4 along with cherrypy installed in my system.. any help is most welcomed.. thanks in advance..
Upvotes: 0
Views: 906
Reputation: 1561
You are trying to post to the file instead of one of the functions within.
First you need to start the cherrypy server on your file. I'm going to assume you have got a correctly set up cherrypy script.
$ python mypgm.py
This should start up your cherrypy server. Lets assume its running on 0.0.0.0:8080, which means port 8080 all ip network interfaces on your server.
You would now need to set up some kind of redirect in you nginx or apache config, As a HTML form cannot be posted to a port different to the port that your html page is running on (which i assume will be port 80)
For example yourserver.com/api/ would need to be redirected to yourserver.com:8080
Then finally change your HTML to point there instead, and append whichever function you want to receive it.
<form action="http://localhost/api/thefunction">
Upvotes: 1