HTML FORM AND PYTHON

Diez B. Roggisch deets at nospam.web.de
Fri Jun 13 07:47:09 EDT 2008


subhabrata.iisc at hotmail.com schrieb:
> Dear Members of the group,
> I have a small question, if you can help me to find the answer.
> I have one function:
> def add_string(n):
>         print “Print Two strings”
>         print “Print the First String”
>         a1=raw_input(“PRINT THE FIRST STRING”)
>         a2=raw_input(“PRINT THE SECOND STRING”)
>         print “CONCATENATING THE TWO GIVEN STRINGS”
>         a3=a1+a2
>         print “THE RESULT IS”
>         print a3
> 
> Now, I have designed one HTML form which has two input fields for text
> and an output field for the result.
> 
> I like to bind the python program into HTML form.
> i) Is there any way I can keep both my existing python code and HTML
> code and bind them? If any one can suggest with example.

No. The above code works with user-interation at certain points of the 
program. That can't be (easily, and especially not with the above 
functionality) translated into the http-paradigm where each operation is 
embedded into a request/resonse-cycle, with the need for explicit or 
implicit state-keeping over these cycles.

> ii) Do I have to write the whole code in a way in python so that it
> would work the function as well as generate HTML form I am looking
> for? If any one can suggest with example.

For this *trivial* example, I can only say: there isn't enough to be 
worth abstracting.

> iii) Is there any other way?

Google python + webframeworks to find a bazillion discussions, opinions, 
examples.

Diez



More information about the Python-list mailing list