Hello All,
I am trying to get information from a form and send it to a python
script without success..
Here is my objective:
User enters data in form --form send variables to python script -->
script runs and output result.
the form code
<form method="post" action="/cgi-bin/script.py" name="coord">En tre com
os dados <input name="data1"><b r>
Entre com os dados <input name="data2"><b r>
Vai magraum <button name="submete"> </button></form>
In my script.py
What I should have to print
something like
Hello the data1 + data 2 = ....
?
Maybe I am stumbling in something very simple, but I cannot find some
working example, and I am totally confused...
Thanks in advance 8 1887
flit wrote:
Hello All,
I am trying to get information from a form and send it to a python
script without success..
Here is my objective:
User enters data in form --form send variables to python script -->
script runs and output result.
the form code
<form method="post" action="/cgi-bin/script.py" name="coord">En tre com
os dados <input name="data1"><b r>
Entre com os dados <input name="data2"><b r>
Vai magraum <button name="submete"> </button></form>
In my script.py
What I should have to print
something like
Hello the data1 + data 2 = ....
?
Maybe I am stumbling in something very simple, but I cannot find some
working example, and I am totally confused...
Thanks in advance
Untested, without error checking. Caveat emptor:
import cgi
import cgitb; cgitb.enable() # optional error handling
form = cgi.FieldStorag e()
d1 = form["data1"].value
d2 = form["data2"].value
print """\
Content-type: text/plain
Hello: the data were: %s and %s""" % (d1, d2)
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Man....
Very thanks...
I really try to find some source of good and simple and nothing..
Many thanks you are a great help!
Steve Holden wrote:
flit wrote:
Hello All,
I am trying to get information from a form and send it to a python
script without success..
Here is my objective:
User enters data in form --form send variables to python script -->
script runs and output result.
the form code
<form method="post" action="/cgi-bin/script.py" name="coord">En tre com
os dados <input name="data1"><b r>
Entre com os dados <input name="data2"><b r>
Vai magraum <button name="submete"> </button></form>
In my script.py
What I should have to print
something like
Hello the data1 + data 2 = ....
?
Maybe I am stumbling in something very simple, but I cannot find some
working example, and I am totally confused...
Thanks in advance
Untested, without error checking. Caveat emptor:
import cgi
import cgitb; cgitb.enable() # optional error handling
form = cgi.FieldStorag e()
d1 = form["data1"].value
d2 = form["data2"].value
print """\
Content-type: text/plain
Hello: the data were: %s and %s""" % (d1, d2)
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
A good starting place would be the documentation on python.org.
In this case, the python library reference would have been helpful: http://docs.python.org/lib/lib.html
Cheers,
Cliff
flit wrote:
Man....
Very thanks...
I really try to find some source of good and simple and nothing..
Many thanks you are a great help!
Steve Holden wrote:
>flit wrote:
>>Hello All,
I am trying to get information from a form and send it to a python script without success.. Here is my objective:
User enters data in form --form send variables to python script --> script runs and output result.
the form code
<form method="post" action="/cgi-bin/script.py" name="coord">En tre com os dados <input name="data1"><b r>
Entre com os dados <input name="data2"><b r> Vai magraum <button name="submete"> </button></form>
In my script.py
What I should have to print something like
Hello the data1 + data 2 = ....
?
Maybe I am stumbling in something very simple, but I cannot find some working example, and I am totally confused... Thanks in advance
Untested, without error checking. Caveat emptor:
import cgi import cgitb; cgitb.enable() # optional error handling
form = cgi.FieldStorag e()
d1 = form["data1"].value d2 = form["data2"].value
print """\ Content-type: text/plain
Hello: the data were: %s and %s""" % (d1, d2)
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden
Sorry but for a totally newbie the lib doccumentation doesnt help..
The target audience for the docs are for "grown ups" programmers..
I think I will do some tutorial, in baby steps...
J. Clifford Dyer wrote:
A good starting place would be the documentation on python.org.
In this case, the python library reference would have been helpful:
http://docs.python.org/lib/lib.html
Cheers,
Cliff
flit wrote:
Man....
Very thanks...
I really try to find some source of good and simple and nothing..
Many thanks you are a great help!
Steve Holden wrote:
flit wrote: Hello All,
I am trying to get information from a form and send it to a python script without success.. Here is my objective:
User enters data in form --form send variables to python script --> script runs and output result.
the form code
<form method="post" action="/cgi-bin/script.py" name="coord">En tre com os dados <input name="data1"><b r>
Entre com os dados <input name="data2"><b r> Vai magraum <button name="submete"> </button></form>
In my script.py
What I should have to print something like
Hello the data1 + data 2 = ....
?
Maybe I am stumbling in something very simple, but I cannot find some working example, and I am totally confused... Thanks in advance
Untested, without error checking. Caveat emptor:
import cgi
import cgitb; cgitb.enable() # optional error handling
form = cgi.FieldStorag e()
d1 = form["data1"].value
d2 = form["data2"].value
print """\
Content-type: text/plain
Hello: the data were: %s and %s""" % (d1, d2)
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
flit a écrit :
Hello All,
I am trying to get information from a form and send it to a python
script without success..
Here is my objective:
User enters data in form --form send variables to python script -->
script runs and output result.
<OT topic="HTTP">
If the script has side-effects (adding/updating/deleting database
records, writing files, etc), the script should not "output results",
but redirect to another url where the user can see these results.
Else - if the script doesn't have side-effects (ie :a search form, ...),
then the HTTP method should be "GET", not "POST".
</OT>
the form code
<form method="post" action="/cgi-bin/script.py" name="coord">En tre com
os dados <input name="data1"><b r>
Entre com os dados <input name="data2"><b r>
Vai magraum <button name="submete"> </button></form>
<OT topic="HTML">
button elements don't submit the form - they in fact don't do anything
unless you attach behaviour to them with javascript. What you want here
is an input type='submit'.
Also, the "button" tag doesn't require a end tag.
<form method="POST" action="/cgi-bin/script.py" name="coord">
<label for="data1">Ent re com os dados</label>
<input type="text" name="data1" id="data1"><br >
<label for="data2">Ent re com os dados </label>
<input type="text" name="data2" id="data2"><br >
Vai magraum <input type="submit" name="submete">
</form>
</OT>
(cf Steve's answer and the cgi module's doc for your problem)
Bruno Desthuilliers wrote:
flit a écrit :
>>Hello All,
I am trying to get information from a form and send it to a python script without success.. Here is my objective:
User enters data in form --form send variables to python script --> script runs and output result.
<OT topic="HTTP">
If the script has side-effects (adding/updating/deleting database
records, writing files, etc), the script should not "output results",
but redirect to another url where the user can see these results.
Else - if the script doesn't have side-effects (ie :a search form, ...),
then the HTTP method should be "GET", not "POST".
</OT>
>>the form code
<form method="post" action="/cgi-bin/script.py" name="coord">En tre com os dados <input name="data1"><b r>
Entre com os dados <input name="data2"><b r> Vai magraum <button name="submete"> </button></form>
<OT topic="HTML">
button elements don't submit the form - they in fact don't do anything
unless you attach behaviour to them with javascript. What you want here
is an input type='submit'.
Also, the "button" tag doesn't require a end tag.
<form method="POST" action="/cgi-bin/script.py" name="coord">
<label for="data1">Ent re com os dados</label>
<input type="text" name="data1" id="data1"><br >
<label for="data2">Ent re com os dados </label>
<input type="text" name="data2" id="data2"><br >
Vai magraum <input type="submit" name="submete">
</form>
</OT>
(cf Steve's answer and the cgi module's doc for your problem)
So what problem were you talking about?
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Bruno Desthuilliers wrote:
(snip)
<OT topic="HTML">
(snip)
Also, the "button" tag doesn't require a end tag.
oops ! Sorry, your syntax was ok - button elements actually requires the
end tag.
my bad :(
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
Good point. I forget sometimes, because that's how I learned, but I
came in with some background in other scripting languages, so I guess I
knew what I was looking for.
Thanks.
Cliff
flit wrote:
Sorry but for a totally newbie the lib doccumentation doesnt help..
The target audience for the docs are for "grown ups" programmers..
I think I will do some tutorial, in baby steps...
J. Clifford Dyer wrote:
>A good starting place would be the documentation on python.org.
In this case, the python library reference would have been helpful:
http://docs.python.org/lib/lib.html
Cheers, Cliff
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Irmen de Jong |
last post by:
QOTW: "To make the instructions even friendlier it would also help if 'but
Whatever You Do DON'T UNZIP THE FREAKIN' THING - This Means YOU John Latter!'
were in large, bold, and underlined type. And preferably a different colour."
-- John Latter,
on Python's install instructions
"
What's more, these are three of Python's greatest *strengths*. We
resist all attempts to change these, and we (at least I) avoid other
languages because...
|
by: Raymond Hettinger |
last post by:
QOTW: "Python seems to encourage and reward incremental effort, and it leads
one to explore extensions and improvements to programs because the language
makes it relatively easy to see how to do the extensions." -- Ron Stephens
"When writing programs in Python, write Python programs" -- Jeff Epler's
advice to those forcing themselves to write code using idioms learned in
other languages
"Oh come on, now, just because Java does it..."...
|
by: Raymond Hettinger |
last post by:
QOTW: "the DOM API is designed for consultants, not for humans or
computers" -- Fredrik Lundh giving solace to a confused DOM API user
QOTW: "Python enjoys making tradeoffs that drive *someone* crazy
<wink>" -- Michael Hudson's signature line attributed to Tim Peters
Discussion
----------
Alex Martelli shows the classic example for the "for-else"
|
by: Cameron Laird |
last post by:
QOTW: praise than which there is no higher: "I like the Python Cookbook,
edited by Alex Martelli and David Ascher. I keep that one in my bathroom."
Terry Carroll
"e needed something more complex and expensive because the response to
any IT problem is to spend more money making things more complex."
Robert X. Cringely on voting machines
http://www.pbs.org/cringely/pulpit/pulpit20031204.html
|
by: Cameron Laird |
last post by:
QOTW: "Well, to do what I've done so far in Java would have taken at least
5 and probably more like 10 times the code I've written. A simple yet
decent TCP chat server in about 30 lines of code is something I never
considered possible before looking at Python." -- Qp
http://groups.google.com/groups?selm=k4y0c.7173%24ED1.3250%40fe03.usenetserver.com
"Python is built on a small set of entirely uninteresting control structures,
designed...
| |
by: John J Lee |
last post by:
QOTW: "...simple genexps will work fine anyway almost all the time, so
it doesn't appear to matter much that devious uses will have nightmarish
semantics." -- Tim Peters on Generator Expressions
"It looks like ... a developer's cookbook (eg. the O'Reilly Python
cookbook) but with less Reilly and more "Oh?"."
-- Paul Boddie, on the user-commented PHP documentation
Andrew Bennetts discovers, without realising it, an obscure-but-useful
|
by: Craig Ringer |
last post by:
QOTW: "Such infrastructure building is in fact fun and instructive -- as
long as you don't fall into the trap of *using* such complications in
production code, where Python's simplicity rules;-)." -- Alex Martelli
http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/41a6c0e1e260cd72/
"C++ to Python is a steep 'unlearning' curve..." -- Philip Smith
"URK -- _my_ feeling is that we have entirely *too many* options for...
|
by: Simon Brunning |
last post by:
QOTW: "" - John Machin, snipping a section of Perl code.
"What sort of programmer are you? If it works on your computer, it's done,
ship it!" - Grant Edwards
Guido invites us to comment on PEP 343. This Python Enhancement
Proposal includes a 'with' statement, allowing you simply and
reliably wrap a block of code with entry and exit code, in which
resources can be acquired and released. It also proposes enhancements
|
by: Frank Millman |
last post by:
Hi all
I need to pass data between a server program and a client program, both
written in Python.
My first thought was to use xml. The server builds up an xml string,
without using any xml tools. The client uses Sax to parse the string
received. Here is an example.
The server passes to the client the widgets required to set up a
|
by: Cameron Laird |
last post by:
QOTW: "Dictionaries are one of the most useful things in Python. Make sure
you know how to take adavantage of them..." - Jeremy Sanders
"Python has consistently failed to disappoint me." - Tal Einat
"super() only works on new-style classes ..." and "has its own
set of gotchas":
http://groups.google.com/group/comp.lang.python/msg/f44c8c09e1593dcf
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |